VBScript program demonstrating how to read user Distinguished Names from a text file and add the users to a group. The text file name and the group name are passed to the program as arguments. The program uses the LDAP provider to bind to the group and user objects.

The program uses the RootDSE object to retrieve the DNS domain name. The NameTranslate object is used to convert the DNS domain name to the NetBIOS domain name. Then the NameTranslate object is used again to convert the group name (assumed to be the sAMAccountName) to the AdsPath required to bind to the group object with the LDAP provider. The program checks that two arguments have been specified. Otherwise a syntax message is displayed. The program handles invalid text file names and invalid user names. The program CreateUserList2.vbs can be used to create the text file of user Distinguished Names. The text file should be edited to only include the names desired.

The user Distinguished Name is the AdsPath required by the LDAP provider. It includes the common name of the user (the "cn" attribute, also referred to as the "Full Name"), the OU or container in which the user object resides, and the DNS domain name.

This program should work on any 32-bit Windows client that can log onto the domain. Windows NT and Windows 98/95 clients should have DSClient installed. If DSClient is not installed, they need WSH and ADSI installed.

AddToGroup2.txt <<-- Click here to view or download the program