Recipe 17.5 Finding the Application Partitions Hosted by a Server

17.5.1 Problem

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.

17.5.2 Solution

17.5.2.1 Using a graphical user interface
  1. Open LDP.

  2. From the menu, select Connection Connect.

  3. For Server, enter the name of a DC.

  4. For Port, enter 389.

  5. Click OK.

  6. From the menu, select Connection Bind.

  7. Enter a user and password with the necessary credentials.

  8. Click OK.

  9. From the menu, select Browse Search.

  10. For BaseDN, type the DN of the Partitions container (e.g., cn=partitions,cn=configuration,dc=rallencorp, dc=com).

  11. 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>))
  12. For Scope, select One Level.

  13. Click the Options button.

  14. For Attributes, type dnsRoot.

  15. Click OK.

  16. Click Run.

17.5.2.2 Using a command-line interface

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>))"
17.5.2.3 Using VBScript
' 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

17.5.3 Discussion

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.

17.5.4 See Also

Recipe 17.4 for finding the replica servers for an application partition



Active Directory Cookbook
Active Directory Cookbook, 3rd Edition
ISBN: 0596521103
EAN: 2147483647
Year: 2006
Pages: 456

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net