[ Team LiB ] |
Recipe 17.5 Finding the Application Partitions Hosted by a Server17.5.1 ProblemYou 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 Solution17.5.2.1 Using a graphical user interface
17.5.2.2 Using a command-line interfaceUse 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 DiscussionAs 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 AlsoRecipe 17.4 for finding the replica servers for an application partition |
[ Team LiB ] |