You want to find the application partitions that a particular server replicates. Before you decommission a server, it is good to check to see if it hosts any application partitions and if so, add another replica server to replace it.
Open LDP.
From the menu, select Connection Connect.
For Server, enter the name of a DC.
For Port, enter 389.
Click OK.
From the menu, select Connection Bind.
Enter a user and password with the necessary credentials.
Click OK.
From the menu, select Browse Search.
For BaseDN, type the DN of the Partitions container (e.g., cn=partitions,cn=configuration,dc=rallencorp, dc=com).
For Filter, enter:
(&(objectcategory=crossRef)(systemFlags:1.2.840.113556.1.4.803:=5) (msDS-NC-Replica-Locations=cn=NTDS Settings,cn=<DomainControllerName>, cn=servers,cn=<SiteName>,cn=sites, cn=configuration,<ForestDN>))
For Scope, select One Level.
Click the Options button.
For Attributes, type dnsRoot.
Click OK.
Click Run.
Use the following command to find all of the application partitions hosted by a domain controller. To run this command, you need the distinguished name of the forest root domain (<ForestDN>), the common name of the DC's server object (<DomainControllerName>), and the common name of the site object the server is in (<SiteName>).
> dsquery * "cn=partitions,cn=configuration,<ForestDN>" -scope onelevel -attr[RETURN] dnsRoot -filter "(&(objectcategory=crossRef)(systemFlags:1.2.840.113556.1.4.803:=5)[RETURN] (msDS-NC-Replica-Locations=cn=NTDS Settings,cn=<DomainControllerName>,[RETURN] cn=servers,cn=<SiteName>,cn=sites, cn=configuration,<ForestDN>))"
' This code finds the application partitions hosted by the specified server. ' ------ SCRIPT CONFIGURATION ------ ' Hostname of server to add as replica for app partition. ' This needs to match the common name for the DC's server object. strServer = "<DomainControllerName>" ' e.g. dc01 ' ------ END CONFIGURATION --------- ' ---------------------------------------------------------- ' First need to find the NTDS Settings object for the server ' ---------------------------------------------------------- set objRootDSE = GetObject("LDAP://RootDSE") strBase = "<LDAP://cn=Sites," & _ objRootDSE.Get("ConfigurationNamingContext") & ">;" strFilter = "(&(objectcategory=server)(cn=" & strServer & "));" strAttrs = "cn,distinguishedName;" strScope = "subtree" set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope) if objRS.RecordCount <> 1 then WScript.Echo "Did not find a match for server " & strServer WScript.Quit else objRS.MoveLast strServerDN = "cn=NTDS Settings," & _ objRS.Fields("distinguishedName").Value Wscript.Echo "Found server object: " WScript.Echo strServerDN Wscript.Echo end if ' ------------------------------------------------------------------ ' Find the crossRef objects that are hosted by the server ' ------------------------------------------------------------------ strBase = "<LDAP://cn=Partitions," & _ objRootDSE.Get("ConfigurationNamingContext") & ">;" strFilter = "(&(objectcategory=crossRef)" & _ "(msDS-NC-Replica-Locations=" & strServerDN & "));" strAttrs = "nCName;" strScope = "onelevel" set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope) if objRS.RecordCount = 0 then WScript.Echo "Server " & strServer & _ " does not host any application partitions" WScript.Quit else Wscript.Echo "App partitions hosted by server " & strServer & ": " objRS.MoveFirst while not objRS.EOF WScript.Echo " " & objRS.Fields("nCName").Value objRS.MoveNext wend end if
As described in Recipe 17.3 and Recipe 17.4, the msDS-NC-Replica-Locations attribute on crossRef objects contains the list of replica servers for a given application partition. Each of the solutions illustrates how to perform a query using this attribute to locate all of the application partitions a particular domain controller is a replica server for. For the GUI and CLI solutions, you need to know the distinguished name of the nTDSDSA object for the target domain controller. The VBScript solution tries to dynamically determine the distinguished name given a server name.
Recipe 17.4 for finding the replica servers for an application partition