• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

How to automatically move users from OU-A to Group-A

I need to find a way to automatically move users from organizational unit "A" into security group A. Anytime a new user gets created in OU-A, i have to manually add them to group-A. Can we automate this?

Thanks!
0
enzerj
Asked:
enzerj
1 Solution
 
smashpmk712Commented:
You can setup a "template" user just like a standard user and add them to group-A and then just copy the user account every time you want to create a new user.
0
 
enzerjAuthor Commented:
I cannot do that because all users in OU-A get automatically created from an online portal.
0
 
smashpmk712Commented:
Do you have control over the online portal? IE can you change how the user is created from the portal?
0
 
steezyCommented:
Replace "CN=Applicants" with "CN=<yourgroupname>"
Replace "OU=Applicants" with "OU=<yourOUname>"
Replace "DC=domain" with "DC=<yourdomainname>"
Replace "DC=TLD" with "DC=<yourTLD>"
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objGroup = GetObject("LDAP://CN=Applicants,OU=Applicants,DC=domain,DC=TLD")
 
For Each strMember in objGroup.Member
    objDictionary.Add strMember, strMember   
Next
Set objOU = GetObject("LDAP://OU=Applicants,DC=domain,DC=TLD")
objOU.Filter = Array("User")
For Each objUser in objOU
    strUser = objUser.distinguishedName    
    If Not objDictionary.Exists(strUser) Then
       objGroup.Add(objUser.ADsPath)
    End If       
Next

Open in new window

0
 
cantorisCommented:
You'll need to edit the names and paths to the OU and the Group below:

dsquery user "OU=OU-A,DC=contoso,DC=com" | dsmod group "CN=Group-A,CN=Users,DC=contoso,DC=com" -addmbr
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now