public IUser CreateUser(LdapName name) { Guard.CheckNull(name, nameof(name)); Logger.Debug("Create user {User} in {DN}.", name, DistinguishedName); var child = DirectoryEntry.Children.Add( new Rdn(NamingAttribute.Cn, name).ToString(), SchemaClassName.User); child.Properties[DirectoryProperty.SamAccountName].Add(name.ToString()); var user = new User(child); user.Save(); children.Value.Add(user); Logger.Debug("User {User} successfully created in {DN}.", name, DistinguishedName); return(user); }
public IGroup CreateGroup(LdapName name) { Guard.CheckNull(name, nameof(name)); Logger.Debug("Create group {Group} in {DN}.", name, DistinguishedName); var child = DirectoryEntry.Children.Add( new Rdn(NamingAttribute.Cn, name).ToString(), SchemaClassName.Group); child.Properties[DirectoryProperty.SamAccountName].Add(name.ToString()); var group = new Group(child); group.Save(); children.Value.Add(group); Logger.Debug("Group {Group} successfully created in {DN}.", name, DistinguishedName); return(group); }