Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public static Rdn Parse(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentOutOfRangeException(
                          null,
                          ErrorMessages.Rdn_ArgumentOutOfRangeException_InvalidValue);
            }

            var segments = value.Split('=');

            if (segments.Length != 2)
            {
                throw new ArgumentOutOfRangeException(
                          null,
                          string.Format(ErrorMessages.Rdn_ArgumentOutOfRangeException_InvalidParseValue, value));
            }

            var namingAttribute = Enumeration.FromName <NamingAttribute>(segments.First());
            var name            = new LdapName(segments.Last());

            return(new Rdn(namingAttribute, name));
        }
Esempio n. 4
0
        public IOrganizationalUnit CreateOrganizationalUnit(LdapName name)
        {
            Guard.CheckNull(name, nameof(name));

            Logger.Debug("Create organizational unit {OrganizationalUnit} in {DN}.", name, DistinguishedName);

            var child = DirectoryEntry.Children.Add(
                new Rdn(NamingAttribute.Ou, name).ToString(),
                SchemaClassName.OrganizationalUnit);

            var ou = new OrganizationalUnit(child);

            ou.Save();

            children.Value.Add(ou);

            Logger.Debug(
                "Organizational unit {OrganizationalUnit} successfully created in {DN}.",
                name,
                DistinguishedName);

            return(ou);
        }
Esempio n. 5
0
 public Rdn([NotNull] NamingAttribute namingAttribute, [NotNull] LdapName name)
 {
     this.namingAttribute = Guard.CheckNull(namingAttribute, nameof(namingAttribute));
     value = Guard.CheckNull(name, nameof(name));
 }