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

Posted on 2009-02-20
Last Modified: 2013-12-24
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?

Question by:enzerj
    LVL 3

    Expert Comment

    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.

    Author Comment

    I cannot do that because all users in OU-A get automatically created from an online portal.
    LVL 3

    Expert Comment

    Do you have control over the online portal? IE can you change how the user is created from the portal?
    LVL 3

    Accepted Solution

    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   
    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
        End If       

    Open in new window

    LVL 16

    Expert Comment

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
    Read about achieving the basic levels of HRIS security in the workplace.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now