by Brad
30. October 2007 09:35
Here's how to create a Domain Local Group in Active Directory using C#
using (DirectoryEntry myDE =
new DirectoryEntry(LDAPPath, LDAPUsername, LDAPPassword))
{
DirectoryEntries myEntries = myDE.Children;
using (DirectoryEntry group = myEntries.Add("CN=" + Name, "group"))
{
group.Properties["sAMAccountName].Add(Name);
group.Properties["groupType].Add("-2147483644");
group.CommitChanges();
}
}
Also one thing to note - if the Name ends in a full stop it will fail with a really non-helpful message of "A device attached to the system is not functioning."
37afd398-f492-41d9-8a2b-04b00931a7c3|0|.0
Tags:
C#