I know how to create groups, the problem is that I need to create Groups with diffrent scopes.
For example:
Security,Universal
or Distribution, Global
I have found the code, but I dont understand the "enum" part.
How to join two enums if I want the group (for example) to be global+security.
or: Universal+distribution.
I tried many things, but I couldnt get the proper results.
Thx for help!
using System.DirectoryServices;
using System.Reflection;
public class ADGroup
{
private String ADGRPOUP = "group";
// Grouptype-Definition
enum GrpType : uint
{
UnivGrp = 0x08,
DomLocalGrp = 0x04,
GlobalGrp = 0x02,
SecurityGrp = 0x80000000
}
DirectoryEntry ent = new DirectoryEntry("LDAP://RootDSE");
String str = (String)ent.Properties["defaultNamingContext"][0];
deAD = new DirectoryEntry("LDAP://" + str);
GrpType gt = GrpType.GlobalGrp | GrpType.SecurityGrp;
int typeNum = (int)gt;
DirectoryEntry ou = deAD.Children.Find("OU=Users");
DirectoryEntry group = ou.Children.Add("cn=myGroupName", ADGRPOUP );
group.Properties["sAMAccountName"].Add("myGroupName");
group.Properties["description"].Add(" description myGroupName");
group.Properties["groupType"].Add(typeNum);
group.CommitChanges();
}