How To Start the RUS Programmatically (306866)



The information in this article applies to:

  • Microsoft Exchange Server 2003 Standard Edition
  • Microsoft Windows 2000 Server
  • Microsoft Exchange 2000 Enterprise Server
  • Microsoft Exchange 2000 Server
  • Microsoft Active Directory Services Interface, System Component
  • Microsoft Active Directory Services Interface, Microsoft Active Directory Client

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 "true".
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("LDAP://RootDSE")
strdn = RootDse.Get("defaultNamingContext")
Set oConfig = GetObject("LDAP://" & strdn)
strDomainName = oConfig.Get("name")
strConfigurationNC = RootDse.Get("ConfigurationNamingContext")
strExchangeOrg = FindAnyOrg(strConfigurationNC)
strRUS = "CN=Recipient Update Service (" & strDomainName & "),CN=Recipient Update Services," & _
            "CN=Address Lists Container,CN=" & strExchangeOrg & ",CN=Microsoft Exchange,CN=Services," & _
         "CN=Configuration," & strdn
Set objRUS = GetObject("LDAP://" & strRUS)
objRUS.Put "msExchReplicateNow", True
objRUS.SetInfo
End Sub

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

   ' Open the Connection
   oConnection.Provider = "ADsDSOObject"
   oConnection.Open "ADs Provider"

   ' Build the query to find the private Exchange Organization
   strQuery = "<LDAP://" & strConfigurationNC & ">;(objectCategory=msExchOrganizationContainer);name,adspath;subtree"
   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("name").Value)
   Else
     FindAnyOrg = ""
   End If

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

REFERENCES

For information on Finding the Exchange Organization Name using Microsoft Visual C++, see: For information on checking the progress of the RUS, see:

246127 XADM: How to Check the Progress of the Recipient Update Service


Modification Type:MajorLast Reviewed:9/1/2006
Keywords:kbDSWADSI2003Swept kbhowto KB306866