Search code examples
active-directoryldapactive-directory-groupactivedirectorymembership

Assign multiple groups to Ldap User programmatically


Is it possible to assign multiple groups to a user that's programmatically added to LDAP. If yes, what should be the format followed.


Solution

  • We don’t assign group/groups to a user. For Correcting you we generally do assign a user as a member of a group.

    Hoping you are already setup Active Directory in Your Environment. If not, you can refer this link

    For adding a user to Multiple groups, you can use this PowerShell Script.

    $Groups = @("group1","group2","groupN")
    
    foreach($group in $groups){
        Add-ADGroupMember -Identity $group -Members "UserName"
    }
    

    Reference : https://community.spiceworks.com/topic/2128061-powershell-adding-a-single-user-to-multiple-groups