Click here to Skip to main content
15,936,247 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everybody,

Is there a way to set multiple groups in Active Directory ?

For example :

What I have tried:
C#
string group = "User02"; 
DirectoryEntry grp;
grp = aduser.Children.Find($"CN={group},OU=Gruppen,OU=FIR", "group")
grp = aduser.Children.Add(group, "group");
Posted
Updated 25-May-20 2:14am
v3
Comments
Richard Deeming 19-May-20 12:47pm    
REPOST
You have already posted this in the ASP.NET forum:
How do I multiple group in Active Directory ? - ASP.NET Discussion Boards[^]

You add them one a time.

It doesn't matter if you're adding a group to a bunch of groups, or adding a bunch of groups to a single group. You add them one at a time.
 
Share this answer
 
Comments
ugurarslanm 19-May-20 13:25pm    
Thx and What is the Solution ?
I want to add multiple groups.

For example :
In my project, when I have selected the Checkbox, the user must be created with multiple groups


string group1
string group2
string group3
Dave Kreskowiak 19-May-20 15:31pm    
You already have the solution. You do what you're doing for one group for each of the groups you want to add.
C#
List<string> groupToAdd = new List<string>();

foreach(var group_ in groupToAdd)
                
{
                    
     var grp = aduser.Children.Find($"CN={group_},OU=XXX,OU=XXX", "group");
     if (grp != null)                    
     {
     
         grp.Invoke("Add", new object[] { newUser.Path.ToString() });
     }
                
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900