Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Add User To Group
 

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.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
          - Ad User Information Query
          - Add Machine To Domain
          - Add User To Group
          - Create Group
          - Create Ou Structure
          - Enumerate Ad Users
          - Enumerate Group Members
          - Move Users And Groups Between Ous
          - Raise Domain Functional Level
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers