Vbscript / Active Directory / Add User To Group
This script adds a specified user to a global security group making them a member of the group.
AddUserToGroup "OU=users,OU=staff,", "CN=student1,", "CN=students,"
Sub AddUserToGroup(strOU, strUser, strGroup)
Set objRootLDAP = GetObject("LDAP://RootDSE") strDNSDomain = objRootLDAP.Get("DefaultNamingContext")
Set objUser = GetObject("LDAP://" & strUser & strOU & strDNSDomain) Set objGroup = GetObject("LDAP://" & strGroup & strOU & strDNSDomain)
objGroup.add(objUser.ADsPath)
End Sub
Please note that a disclaimer applies to any code on this page.
|