Is there a way in C# to add a domain group to a local group on the machine? I need to add groups, not users. I have read a lot of articles about adding users, but nothing on adding groups. When I try to modify the code to use the group name, it has failed. Here is the code I am trying to use:
[code]
private
void _addGroups(){
try{
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"); DirectoryEntry NewUser = AD.Children.Add("Software Development Group", "user");NewUser.CommitChanges();
DirectoryEntry grp;grp = AD.Children.Find(
"Administrators", "group"); if (grp != null) { grp.Invoke("Add", new object[] { NewUser.Path.ToString() }); }}
catch (Exception ex){
MessageBox.Show(ex.StackTrace, ex.Message);}
}
[/code]
Guest UserPosted Jul 2, 2008, 4:05 PM
According to the API docs, you can add individual users or groups to other groups. I don't know if you can add a domain group to a local group with it, though.
charlesPosted Jul 2, 2008, 3:40 PM
Guest UserPosted Jul 2, 2008, 11:06 AM