Now t hat you know how to use ADsPaths to distinguish between different namespaces, we'll demonstrate how to establish a connection and authenticate to the server containing the directory service you want to access. Authenticating a connection isn't always necessary; some directories, such as Active Directory, allow anonymous read-only access to certain parts of the directory tree if you configure it that way. In general though, allowing anonymous access is not a good practice. It can make things much more difficult to troubleshoot if you discover that one of your domain controllers is being impacted by an overzealous client. When using ADSI, if authentication is not done explicitly, the credentials of the account the script is running under will be used. If the account running the script is not part of the Active Directory you want to query or in a trusted domain, you will not be able to do very much. That's why performing explicit authentication in ADSI scripts is generally the best way to go.
If you just want to bind using the current account's credentials
to a directory server to get a reference to an object, use
Dim strPath 'path to the directory server Dim objMyDomain 'root object of the directory strPath = "LDAP://dc=amer,dc=rallencorp,dc=com" Set objMyDomain = GetObject(strPath)
The code begins by declaring two variables with VBScript
statements. The first variable,
strPath, is an ADsPath. The prefix str specifies that this ADsPath ...