Platform SDK: Active Directory, ADSI, and Directory Services |
The ability to retrieve changes that have been made to the directory service can be useful for building applications such as directory synchronization tools.
One important attribute is an object's Update Sequence Number or USN. When a change is made to an object in the Exchange directory, the local directory service modifies the USN on the object to be the next available USN for the server. Each server maintains it's own USN count. Therefore, when a server changes an object, the directory service takes the current USN, increments it and stamps it on the changed object. If an application knows the USN number of the last changed object it received from the server, the next time it makes a request for changes it asks for all directory objects with USNs greater than the last USN it received.
Here is a simple example.
Dim ADOConn As ADODB.Connection Dim ADOCommand As New Command Dim RS As ADODB.Recordset Set ADOConn = CreateObject("ADODB.Connection") ADOConn.Provider = "ADSDSOObject" ADOConn.Open "Active Directory Provider" Set ADOCommand.ActiveConnection = ADOConn ADOCommand.CommandText = "<LDAP://localhost/o=kramerica>;(USN-Changed>=1080);rdn;subtree" Set RS = ADOCommand.Execute While Not RS.EOF Debug.Print (RS.Fields(0)) RS.MoveNext Wend RS.Close Set ADOConn = Nothing Set ADOCommand = Nothing Set RS = Nothing
Note: This example is specific to Exchange Server version 5.5 and below, and is not upwardly compatible with Exchange 6.0. Management and access of Exchange 6.0 Servers should be made through the CDO Exchange Management interfaces instead.