public void Core_CreateGroupBadDistName() { // Get User That Does Not Exist String groupName = $"testgroup_{Utility.GenerateToken( 8 )}"; String groupDistinguishedName = $"GW={groupName},{workspaceName}"; Console.WriteLine($"Create Group [{groupDistinguishedName}] With Bad DistinguishedName"); GroupPrincipal group = null; AdException ex = Assert.Throws <AdException>(() => group = DirectoryServices.CreateGroupPrincipal(groupDistinguishedName)); }
public GroupPrincipal CreateGroupPrincipal() { GroupPrincipal group = DirectoryServices.CreateGroupPrincipal(this.Identity, this.SamAccountName); if (this.Properties?.Count > 0) { group.Save(); // Group Must Exist Before Properties Can Be Updated } UpdateGroupPrincipal(group); return(group); }
public static GroupPrincipal CreateGroup(string workspaceName) { String name = $"testgroup_{Utility.GenerateToken( 8 )}"; String testGroupName = $"CN={name},{workspaceName}"; Console.WriteLine($"Creating Group : [{testGroupName}]"); GroupPrincipal testGroup = DirectoryServices.CreateGroupPrincipal(testGroupName); DirectoryServices.SaveGroup(testGroup); Assert.That(testGroup.Name, Is.EqualTo(name)); return(testGroup); }