DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 12.3 Viewing Unreplicated Changes Between Two Domain Controllers

12.3.1 Problem

You want to find the unreplicated changes between two domain controllers.

12.3.2 Solution

12.3.2.1 Using a graphical user interface
  1. Open the Replication Monitor from the Support Tools (replmon.exe).

  2. From the menu, select View Options.

  3. On the General tab, check the box beside Show Transitive Replication Partners and Extended Data.

  4. Click OK.

  5. In the left pane, right-click on Monitored Servers and select Add Monitored Server.

  6. Use the Add Monitored Server Wizard to add one of the domain controllers you want to compare (I'll call it dc1).

  7. In the left pane, under the server you just added, expand the naming context that you want to check for unreplicated changes.

  8. Right-click on the other domain controller you want to compare (I'll call it dc2) and select Check Current USN and Un-replicated Objects.

  9. Enter credentials if necessary and click OK.

  10. If some changes have not yet replicated from dc2 to dc1, a box will pop up that lists the unreplicated objects.

  11. To find out what changes have yet to replicate from dc1 to dc2, repeat the same steps except add dc2 as a monitored server and check for unreplicated changes against dc1.

12.3.2.2 Using a command-line interface

Run the following two commands to find the differences between two domain controllers. Use the /statistics option to view a summary of the changes:

> repadmin /showchanges <DC1Name> <DC2GUID> <NamingContextDN>
> repadmin /showchanges <DC2Name> <DC1GUID> <NamingContextDN>

The Windows 2000 version of repadmin has a different syntax to accomplish the same thing. Here is the equivalent syntax:

> repadmin /getchanges <NamingContextDN> <DC1Name> <DC2GUID>
> repadmin /getchanges <NamingContextDN> <DC2Name> <DC1GUID>
12.3.2.3 Using VBScript
' This code uses the IADsTools interface to print the unreplicated
' changes for the naming context defined by strNCDN for the DCs 
' defined by strDC1Name and strDC2Name
' ------ SCRIPT CONFIGURATION ------
strNCDN     = "<NamingContextDN>"  ' e.g. dc=rallencorp,dc=com
strDC1Name  = "<DC1Name>"          ' e.g. dc1.rallencorp.com
strDC2Name  = "<DC2Name>"          ' e.g. dc2.rallencorp.com
' ------ END CONFIGURATION ---------

set objIadsTools = CreateObject("IADsTools.DCFunctions")

' ----------------------------------
' Have to get the GUIDs of both servers in order to identify 
' the correct partner in the GetReplicationUSNState call
' ----------------------------------
strDC1GUID = objIadsTools.GetGuidForServer(Cstr(strDC1Name), _
                                           Cstr(strDC1Name),0)
strDC2GUID = objIadsTools.GetGuidForServer(Cstr(strDC2Name), _
                                           Cstr(strDC2Name),0)

' ----------------------------------
' Need to get what each DC thinks is the highest USN for the other 
' The USN is needed in the call to GetMetaDataDifferences to return
' the unreplicated changes 
' ----------------------------------
intRes = objIadsTools.GetReplicationUSNState(Cstr(strDC1Name), _
                                             Cstr(strNCDN),0,0)
if intRes = -1 then
   Wscript.Echo objIadsTools.LastErrorText
   WScript.Quit
end if
for count = 1 to intRes
   if strDC2GUID = objIadsTools.ReplPartnerGuid(count) then
      intDC2USN = objIadsTools.ReplPartnerUSN(count)
   end if
next
if intDC2USN = "" then
   WScript.Echo strDC2Name & " is not a replication partner with " & _
                strDC1Name
end if
intRes = objIadsTools.GetReplicationUSNState(Cstr(strDC2Name), _
                                             Cstr(strNCDN),0,0)
if intRes = -1 then
   Wscript.Echo objIadsTools.LastErrorText
   WScript.Quit
end if
for count = 1 to intRes
   if strDC1GUID = objIadsTools.ReplPartnerGuid(count) then
      intDC1USN = objIadsTools.ReplPartnerUSN(count)
   end if
next
if intDC2USN = "" then
   WScript.Echo strDC1Name & " is not a replication partner with " & _
                strDC2Name
end if

' ----------------------------------
' Now that we have retrieved the highest USN for both partners,
' the GetMetaDataDifferences method will return what needs to be
' replicated
' ----------------------------------
intRes = objIadsTools.GetMetaDataDifferences(Cstr(strDC1Name), _
                                             Cstr(intDC1USN), _
                                             Cstr(strNCDN),0)
if intRes = -1 then
   Wscript.Echo objIadsTools.LastErrorText
   WScript.Quit
end if
WScript.Echo "Data on " & strDC1Name & " but not " & strDC2Name & ":"
for count = 1 to intRes
   WScript.Echo count & ". " & _
                   objIadsTools.MetaDataDifferencesObjectDN(count)
   WScript.Echo vbTab & " Attribute:   " & _
                   objIadsTools.MetaDataDifferencesAttribute(count)
   WScript.Echo vbTab & " Write time:  " & _
                   objIadsTools.MetaDataDifferencesLastWriteTime(count)
   WScript.Echo vbTab & " Orig Server: " & _
                   objIadsTools.MetaDataDifferencesOrigServer(count)
   WScript.Echo vbTab & " Orig USN:    " & _
                   objIadsTools.MetaDataDifferencesOrigUSN(count)
next
WScript.Echo

intRes = objIadsTools.GetMetaDataDifferences(Cstr(strDC2Name), _
                                             Cstr(intDC2USN), _
                                             Cstr(strNCDN), 0)
if intRes = -1 then
   Wscript.Echo objIadsTools.LastErrorText
   WScript.Quit
end if
WScript.Echo "Data on " & strDC2Name & " but not " & strDC1Name & ":"
for count = 1 to intRes
   WScript.Echo count & ". " & _
                 objIadsTools.MetaDataDifferencesObjectDN(count)
   WScript.Echo vbTab & " Attribute:   " & _
                 objIadsTools.MetaDataDifferencesAttribute(count)
   WScript.Echo vbTab & " Write time:  " & _
                 objIadsTools.MetaDataDifferencesLastWriteTime(count)
   WScript.Echo vbTab & " Orig Server: " & _
                 objIadsTools.MetaDataDifferencesOrigServer(count)
   WScript.Echo vbTab & " Orig USN:    " & _
                 objIadsTools.MetaDataDifferencesOrigUSN(count)
next

12.3.3 Discussion

All three solutions show how to display the current unreplicated changes between two domain controllers. The repadmin /showchanges command has several additional options you can use to display the changes, including saving the output to a file for later comparison. Also, with the /statistics option, you can view a summary of the changes.

12.3.4 See Also

See IadsTools.doc in the Support Tools for more information on the IADsTools interface

    [ Team LiB ] Previous Section Next Section