Tuesday, 18 November 2014

How to add Domain Users to Group in Active Directory through vbscript

How to add Domain Users to Group in Active Directory through vbscript

In order to add domain user to domain group first get the group object then get the domain user from active directory, then add user's ADsPath to group as shown in below sample code.
 
Set objGroup = GetObject("LDAP://CN=TestGroup,OU=TestOU,DC=TEST,DC=com")
Set objUser = GetObject("LDAP://CN=TestUser,OU=TestOU,DC=TEST,DC=com")
objGroup.Add(objUser.ADsPath)   
Wscript.echo "Successfully added user TestUser to TestGroup"
  • 0Blogger Comment
  • Facebook Comment