ADLib.ActiveDirectory.CreateGroup C# (CSharp) Method

CreateGroup() public method

Creates a new group
public CreateGroup ( string groupName, System.Boolean isUserGroup = true ) : System.DirectoryServices.AccountManagement.GroupPrincipal
groupName string The name of the new group
isUserGroup System.Boolean If true (default), the new group will be made a subgroup of Domain Users
return System.DirectoryServices.AccountManagement.GroupPrincipal
        public GroupPrincipal CreateGroup(string groupName, Boolean isUserGroup=true)
        {
            GroupPrincipal g = new GroupPrincipal(_GlobalContext, groupName);

            g.Save();

            //Add new group as a subgroup of Domain Users
            //if (isUserGroup)
            //{
            //    GroupPrincipal users = GetOrCreate("Domain Users");
            //    users.Members.Add(g);
            //    users.Save();
            //}

            return g;
        }