Microsoft KB Archive/306866

= How To Start the RUS Programmatically =

Article ID: 306866

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft Exchange Server 2003 Standard Edition
 * Microsoft Windows 2000 Server
 * Microsoft Exchange 2000 Enterprise Server
 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft Active Directory Service Interfaces 2.5
 * Microsoft Active Directory Service Interfaces 2.5

-



This article was previously published under Q306866



SUMMARY
This article demonstrates how to start the Exchange 2000 Recipient Update Service (RUS) programmatically. You may want to do this if you want the RUS to start running without having to wait for the next scheduled time.



MORE INFORMATION
The following code sets the msExchReplicateNow attribute on the RUS for the domain to &quot;true&quot;. Private Sub Command1_Click ' This sample finds the first Exchange Organization and ' starts the server RUS. If you have multiple Exchange ' organizations you will want to modify the code. ' This sample does a serverless bind finding the first DC ' to respond. You may want to modify the code to specify ' a specific server in the Bind statement.

Dim RootDse Set RootDse = GetObject(&quot;LDAP://RootDSE&quot;) strdn = RootDse.Get(&quot;defaultNamingContext&quot;) Set oConfig = GetObject(&quot;LDAP://&quot; & strdn) strDomainName = oConfig.Get(&quot;name&quot;) strConfigurationNC = RootDse.Get(&quot;ConfigurationNamingContext&quot;) strExchangeOrg = FindAnyOrg(strConfigurationNC) strRUS = &quot;CN=Recipient Update Service (&quot; & strDomainName & &quot;),CN=Recipient Update Services,&quot; & _ &quot;CN=Address Lists Container,CN=&quot; & strExchangeOrg & &quot;,CN=Microsoft Exchange,CN=Services,&quot; & _ &quot;CN=Configuration,&quot; & strdn Set objRUS = GetObject(&quot;LDAP://&quot; & strRUS) objRUS.Put &quot;msExchReplicateNow&quot;, True objRUS.SetInfo End Sub

Function FindAnyOrg(strConfigurationNC) Set oConnection = CreateObject(&quot;ADODB.Connection&quot;) Set oCommand = CreateObject(&quot;ADODB.Command&quot;) Set oRecordSet = CreateObject(&quot;ADODB.RecordSet&quot;) Dim strQuery

' Open the Connection oConnection.Provider = &quot;ADsDSOObject&quot; oConnection.Open &quot;ADs Provider&quot;

' Build the query to find the private Exchange Organization strQuery = &quot;;(objectCategory=msExchOrganizationContainer);name,adspath;subtree&quot; oCommand.ActiveConnection = oConnection oCommand.CommandText = strQuery Set oRecordSet = oCommand.Execute

' If we have an Organization then return the first one If Not oRecordSet.EOF Then oRecordSet.MoveFirst FindAnyOrg = CStr(oRecordSet.Fields(&quot;name&quot;).Value) Else FindAnyOrg = &quot;&quot; End If

'Clean Up  oRecordSet.Close oConnection.Close Set oRecordSet = Nothing Set oCommand = Nothing Set oConnection = Nothing End Function

