Connect to Well-Known GUID (VBScript)

This code can be found in Chapter 4 of Active Directory Cookbook, 2nd edition

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' This code illustrates how to bind to the default computers container.
' ------ SCRIPT CONFIGURATION ------
strDomain = "<DomainDNSName>"   ' e.g. apac.rallencorp.com
strWKGUID = "<WKGUID>" ' e.g. "aa312825768811d1aded00c04fd8d5cd"
					' for the default Computers container
' ------ END CONFIGURATION ---------
     
set objRootDSE = GetObject("LDAP://" & strDomain & "/RootDSE")
set objCompContainer = GetObject("LDAP://<WKGUID=" & _
                             strWKGUID & "," & _
                             objRootDSE.Get("defaultNamingContext") & ">" )
WScript.Echo objCompContainer.Get("distinguishedName")

This code has been viewed 1725 times.

New from the creators of TechTasks.com: StatSheet.com