public void AddRange(DirectoryAttributeModification[] attributes)
 {
     if (attributes != null)
     {
         DirectoryAttributeModification[] directoryAttributeModificationArray = attributes;
         int num = 0;
         while (num < (int)directoryAttributeModificationArray.Length)
         {
             DirectoryAttributeModification directoryAttributeModification = directoryAttributeModificationArray[num];
             if (directoryAttributeModification != null)
             {
                 num++;
             }
             else
             {
                 throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
             }
         }
         base.InnerList.AddRange(attributes);
         return;
     }
     else
     {
         throw new ArgumentNullException("attributes");
     }
 }
Exemple #2
0
        public ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attributeName, params object[] values) : this()
        {
            // Store off the distinguished name
            _dn = distinguishedName;

            // validate the attributeName
            if (attributeName == null)
            {
                throw new ArgumentNullException("attributeName");
            }

            DirectoryAttributeModification mod = new DirectoryAttributeModification();

            mod.Operation = operation;
            mod.Name      = attributeName;
            if (values != null)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    mod.Add(values[i]);
                }
            }

            _attributeModificationList.Add(mod);
        }
		public void AddRange(DirectoryAttributeModification[] attributes)
		{
			if (attributes != null)
			{
				DirectoryAttributeModification[] directoryAttributeModificationArray = attributes;
				int num = 0;
				while (num < (int)directoryAttributeModificationArray.Length)
				{
					DirectoryAttributeModification directoryAttributeModification = directoryAttributeModificationArray[num];
					if (directoryAttributeModification != null)
					{
						num++;
					}
					else
					{
						throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
					}
				}
				base.InnerList.AddRange(attributes);
				return;
			}
			else
			{
				throw new ArgumentNullException("attributes");
			}
		}
 public void Insert(int index, DirectoryAttributeModification value)
 {
     if (value == null)
     {
         throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
     }
     base.List.Insert(index, value);
 }
 public int Add(DirectoryAttributeModification attribute)
 {
     if (attribute == null)
     {
         throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
     }
     return base.List.Add(attribute);
 }
 public void Insert(int index, DirectoryAttributeModification value)
 {
     if (value == null)
     {
         throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
     }
     base.List.Insert(index, value);
 }
 public int Add(DirectoryAttributeModification attribute)
 {
     if (attribute == null)
     {
         throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
     }
     return(base.List.Add(attribute));
 }
Exemple #8
0
		static DirectoryAttributeModification ToAttr (DirectoryAttributeOperation operation, string attributeName, params object [] values)
		{
			var a = new DirectoryAttributeModification ();
			a.Name = attributeName;
			a.Operation = operation;
			a.AddRange (values);
			return a;
		}
Exemple #9
0
        public void Insert(int index, DirectoryAttributeModification value)
        {
            if (value == null)
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.NullDirectoryAttributeCollection));
            }

            List.Insert(index, value);
        }
Exemple #10
0
        public int Add(DirectoryAttributeModification attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.NullDirectoryAttributeCollection));
            }

            return(List.Add(attribute));
        }
Exemple #11
0
        static DirectoryAttributeModification ToAttr(DirectoryAttributeOperation operation, string attributeName, params object [] values)
        {
            var a = new DirectoryAttributeModification();

            a.Name      = attributeName;
            a.Operation = operation;
            a.AddRange(values);
            return(a);
        }
        public static ModifyRequest GetModifyPasswordRequest(ILdapUser user, string newPassword)
        {
            var modifyUserPassword = new DirectoryAttributeModification
            {
                Operation = DirectoryAttributeOperation.Replace,
                Name = "userPassword"
            };
            modifyUserPassword.Add(newPassword);

            return new ModifyRequest(user.GetUserDn(), modifyUserPassword);
        }
        public void ModifyPasswordRequest()
        {
            ModifyRequest req = LdapRequestBuilder.GetModifyPasswordRequest(_testUser, "new pwd");

            Assert.AreEqual(UserDn, req.DistinguishedName);

            var attributeModification = new DirectoryAttributeModification
            {
                Operation = DirectoryAttributeOperation.Replace,
                Name = "userPassword",
            };
            attributeModification.Add("new pwd");

            CollectionAssert.AreEqual(req.Modifications[0], attributeModification);
        }
 public void AddRange(DirectoryAttributeModification[] attributes)
 {
     if (attributes == null)
     {
         throw new ArgumentNullException("attributes");
     }
     DirectoryAttributeModification[] modificationArray = attributes;
     for (int i = 0; i < modificationArray.Length; i++)
     {
         if (modificationArray[i] == null)
         {
             throw new ArgumentException(Res.GetString("NullDirectoryAttributeCollection"));
         }
     }
     base.InnerList.AddRange(attributes);
 }
        public void ModifyRequest()
        {
            ModifyRequest req = LdapRequestBuilder.GetModifyRequest(_testUser, DirectoryAttributeOperation.Replace,
                "description",
                "Test Description 2");

            Assert.AreEqual(UserDn, req.DistinguishedName);

            var attributeModification = new DirectoryAttributeModification
            {
                Operation = DirectoryAttributeOperation.Replace,
                Name = "description",
            };
            attributeModification.Add("Test Description 2");

            CollectionAssert.AreEqual(req.Modifications[0], attributeModification);
        }
        public static bool ChangePassword(LdapConnection connection, string userDN, string oldPassword, string newPassword, bool dryRun = false)
        {
            // Create change password request
            DirectoryAttributeModification deleteMod = new DirectoryAttributeModification();
            deleteMod.Name = "unicodePwd";
            deleteMod.Add(Encoding.Unicode.GetBytes("\"" + oldPassword + "\""));
            deleteMod.Operation = DirectoryAttributeOperation.Delete;
            DirectoryAttributeModification addMod = new DirectoryAttributeModification();
            addMod.Name = "unicodePwd";
            addMod.Add(Encoding.Unicode.GetBytes("\"" + newPassword + "\""));
            addMod.Operation = DirectoryAttributeOperation.Add;
            ModifyRequest request = new ModifyRequest(userDN, deleteMod, addMod);

            try
            {
                if (!dryRun)
                {
                    DirectoryResponse response = connection.SendRequest(request);
                    return response.ResultCode == 0;
                }
                else
                {
                    return true;
                }
            }

            catch (DirectoryOperationException ex)
            {
                if (ex.Response.ErrorMessage.StartsWith("0000052D"))
                {
                    throw new Exception("Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirements of the domain.");
                }
                // TODO: Convert to DirectoryOperationException and use better match to give the dsHeuristics exception
                else if (ex.Message == "The object does not exist")
                {
                    throw new Exception("User not allowed to change own password because of missing permission, set dsHeuristics to 0000000001001 on CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,CN=...");
                }
                else
                {
                    throw;
                }
            }
        }
 public ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attributeName, params object[] values) : this()
 {
     this.dn = distinguishedName;
     if (attributeName == null)
     {
         throw new ArgumentNullException("attributeName");
     }
     DirectoryAttributeModification attribute = new DirectoryAttributeModification {
         Operation = operation,
         Name = attributeName
     };
     if (values != null)
     {
         for (int i = 0; i < values.Length; i++)
         {
             attribute.Add(values[i]);
         }
     }
     this.attributeModificationList.Add(attribute);
 }
        public ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attributeName, params object[] values) : this()
        {
            this.dn = distinguishedName;
            if (attributeName == null)
            {
                throw new ArgumentNullException("attributeName");
            }
            DirectoryAttributeModification attribute = new DirectoryAttributeModification {
                Operation = operation,
                Name      = attributeName
            };

            if (values != null)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    attribute.Add(values[i]);
                }
            }
            this.attributeModificationList.Add(attribute);
        }
Exemple #19
0
		public ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attributeName, object[] values) : this()
		{
			this.dn = distinguishedName;
			if (attributeName != null)
			{
				DirectoryAttributeModification directoryAttributeModification = new DirectoryAttributeModification();
				directoryAttributeModification.Operation = operation;
				directoryAttributeModification.Name = attributeName;
				if (values != null)
				{
					for (int i = 0; i < (int)values.Length; i++)
					{
						directoryAttributeModification.Add(values[i]);
					}
				}
				this.attributeModificationList.Add(directoryAttributeModification);
				return;
			}
			else
			{
				throw new ArgumentNullException("attributeName");
			}
		}
Exemple #20
0
 public ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attributeName, object[] values) : this()
 {
     this.dn = distinguishedName;
     if (attributeName != null)
     {
         DirectoryAttributeModification directoryAttributeModification = new DirectoryAttributeModification();
         directoryAttributeModification.Operation = operation;
         directoryAttributeModification.Name      = attributeName;
         if (values != null)
         {
             for (int i = 0; i < (int)values.Length; i++)
             {
                 directoryAttributeModification.Add(values[i]);
             }
         }
         this.attributeModificationList.Add(directoryAttributeModification);
         return;
     }
     else
     {
         throw new ArgumentNullException("attributeName");
     }
 }
		public bool Contains (DirectoryAttributeModification value)
		{
			return List.Contains (value);
		}
		public int Add (DirectoryAttributeModification attribute)
		{
			return List.Add (attribute);
		}
		public void AddRange (DirectoryAttributeModification [] attributes)
		{
			foreach (var a in attributes)
				List.Add (a);
		}
Exemple #24
0
        private ResultCode ModifyUserInGroup(string userName, string groupName, DirectoryAttributeOperation operation)
        {
            if (!this.UserExist(userName))
                return ResultCode.NoSuchObject;
            AdamUser user = this.GetUser(userName);

            if ((user.Groups.Contains(groupName) && operation == DirectoryAttributeOperation.Add))
                return ResultCode.EntryAlreadyExists;
            else if ((!user.Groups.Contains(groupName) && operation == DirectoryAttributeOperation.Delete))
                return ResultCode.NoSuchAttribute;

            string filter = string.Format("(&(objectClass=Group)(distinguishedName=CN={0},{1}))", groupName, this.GroupsDistinguishedName);
            this.OpenConnection();
            SearchRequest srchRequestGroup = new SearchRequest(this.GroupsDistinguishedName, filter, SearchScope.Subtree);
            SearchResponse srchResponseGroup = (SearchResponse)this._adamConnection.SendRequest(srchRequestGroup);
            this.CloseConnection();

            SearchResultEntry srchEntryGrp = srchResponseGroup.Entries[0];
            string groupDN = srchEntryGrp.DistinguishedName;

            DirectoryAttributeModification addMod = new DirectoryAttributeModification();
            addMod.Name = "member";
            addMod.Add(user.DistinguishedName);
            addMod.Operation = operation;
            ModifyRequest modRequestAddUser = new ModifyRequest(groupDN, addMod);
            this.OpenConnection();
            DirectoryResponse modResponseAdduser = this._adamConnection.SendRequest(modRequestAddUser);
            this.CloseConnection();

            return modResponseAdduser.ResultCode;
        }
Exemple #25
0
        public bool SetUserAttribute(string uname, string attribute, string value)
        {
            string userDN = this.GetUserDN(uname);

            try
            {
                DirectoryAttributeModification mod = new DirectoryAttributeModification
                {
                    Name = attribute,
                    Operation = DirectoryAttributeOperation.Replace
                };
                mod.Add(value);
                ModifyRequest req = new ModifyRequest(userDN);
                req.Modifications.Add(mod);
                m_conn.SendRequest(req);
            }
            catch (Exception e)
            {
                m_logger.FatalFormat("can't add attribute:{0} because of error:{1}", attribute, e.Message);
                return false;
            }

            if (attribute.ToLower().Equals("sambapwdlastset"))
            {
                Dictionary<string, List<string>> SearchResult = GetUserAttribValue(userDN, "(objectClass=*)", SearchScope.Subtree, new string[] { "shadowMax", "sambaPwdMustChange" });

                if (SearchResult.ContainsKey("shadowmax") && SearchResult.ContainsKey("sambapwdmustchange"))
                {
                    int shadowMax = 0;

                    try
                    {
                        shadowMax = Convert.ToInt32(SearchResult["shadowmax"].First());
                    }
                    catch (Exception e)
                    {
                        m_logger.FatalFormat("SetUserAttribute: Unable to convert return from GetUserAttribValue to int {0}", e.Message);
                        return false;
                    }

                    if (shadowMax > 0)
                    {
                        TimeMethod time = TimeMethod.methods[Methods.Timestamps];
                        string t = time.time(new TimeSpan(shadowMax, 0, 0, 0));
                        if (!t.Equals("0"))
                            if (!SetUserAttribute(uname, "sambaPwdMustChange", t))
                                return false;
                    }
                }
            }
            return true;
        }
		public void Insert (int index, DirectoryAttributeModification value)
		{
			List.Insert (index, value);
		}
Exemple #27
0
        /// <summary>
        /// On a new/uncommitted entry, check for any in-queue Add / Replace operations on 'propName'
        /// and remove 'value' if present.  On a regular existing entry, queue a deletion of the
        /// specified value.
        /// </summary>
        /// <param name="propName"></param>
        /// <param name="value"></param>
        public void RemoveAttrValue(string attrName, string value)
        {
            CheckForDeletion();

            string propName = attrName.ToLowerInvariant();

            if (this.IsNewEntry)
            {
                if (_changes.ContainsKey(propName))
                {
                    DirectoryAttributeModification dam = _changes[propName];
                    if (dam.Contains(value))
                        dam.Remove(value);
                }
            }
            else
            {
                string key = propName + "*d";

                if (_changes.ContainsKey(key))
                {
                    DirectoryAttributeModification dam = _changes[key];
                    if (!dam.Contains(value))
                        dam.Add(value);
                }
                else
                {
                    DirectoryAttributeModification dam = new DirectoryAttributeModification();
                    dam.Operation = DirectoryAttributeOperation.Delete;
                    dam.Name = propName;
                    dam.Add(value);
                    _changes[key] = dam;
                }
            }
        }
Exemple #28
0
 public void Remove(DirectoryAttributeModification value)
 {
     List.Remove(value);
 }
Exemple #29
0
        /// <summary>
        /// Replace the values of 'propName' with 'values'.  If there is already an in-flight Replace request on
        /// 'propName', this method will add to its values.
        /// </summary>
        /// <param name="propName"></param>
        /// <param name="values"></param>
        public void SetAttr(string attrName, object[] values)
        {
            CheckForDeletion();
            attrName = attrName.ToLowerInvariant();

            DirectoryAttributeModification dam;

            if (_changes.ContainsKey(attrName))
            {
                dam = _changes[attrName];

                if (dam.Operation != DirectoryAttributeOperation.Replace)
                {
                    if (this.ConflictMode == ConflictModes.Error)
                    {
                        throw new IncompatibleMutationException(String.Format(
                            "Change buffer already contains a request to modify {0} as {1}",
                            attrName, dam.Operation));
                    }
                    else
                    {
                        logger.Info("Overriding {0} request on attr {1} with Replace", dam.Operation, attrName);

                        dam = new DirectoryAttributeModification();
                        dam.Name = attrName;
                        dam.Operation = DirectoryAttributeOperation.Replace;
                        _changes[attrName] = dam;
                    }
                }
            }
            else
            {
                logger.Debug("Preparing replacement operation on attr {0}", attrName);

                dam = new DirectoryAttributeModification();
                dam.Name = attrName;
                dam.Operation = DirectoryAttributeOperation.Replace;
                _changes[attrName] = dam;
            }

            foreach (object o in values)
            {
                if (!dam.Contains(o))
                {
                    if (o is byte[])
                    {
                        dam.Add((byte[])o);
                    }
                    else if (o is string)
                    {
                        dam.Add((string)o);
                    }
                    else if (o is Uri)
                    {
                        dam.Add((Uri)o);
                    }
                    else
                    {
                        throw new ArgumentException("No support for type " + o.GetType().FullName, "values");
                    }
                    logger.Debug("Added value to collection {0} of {1}", attrName, o);
                }
                else
                {
                    logger.Debug("Collection {0} already contains value {1}", attrName, o);
                }
            }
        }
Exemple #30
0
 public int IndexOf(DirectoryAttributeModification value)
 {
     return(List.IndexOf(value));
 }
Exemple #31
0
 public void Insert(int index, DirectoryAttributeModification value)
 {
     List.Insert(index, value);
 }
Exemple #32
0
 public bool Contains(DirectoryAttributeModification value)
 {
     return(List.Contains(value));
 }
Exemple #33
0
 public int Add(DirectoryAttributeModification attribute)
 {
     return(List.Add(attribute));
 }
		public static void Serialize(XmlDictionaryWriter writer, DirectoryAttributeModification attribute)
		{
			ChangeOperation changeOperation = ChangeOperation.None;
			DirectoryAttributeOperation operation = attribute.Operation;
			switch (operation)
			{
				case DirectoryAttributeOperation.Add:
				{
					changeOperation = ChangeOperation.Add;
					break;
				}
				case DirectoryAttributeOperation.Delete:
				{
					changeOperation = ChangeOperation.Delete;
					break;
				}
				case DirectoryAttributeOperation.Replace:
				{
					changeOperation = ChangeOperation.Replace;
					break;
				}
			}
			AttributeTypeAndValueSerializer.InternalSerialize(writer, changeOperation, AttributeNs.LookupNs(attribute.Name, SyntheticAttributeOperation.Write), attribute.Name, attribute);
		}
		public void CopyTo (DirectoryAttributeModification [] array, int index)
		{
			List.CopyTo (array, index);
		}
		public static void Serialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, DirectoryAttributeModification attribute)
		{
			AttributeTypeAndValueSerializer.InternalSerialize(writer, ChangeOperation, AttributeNs.LookupNs(attribute.Name, SyntheticAttributeOperation.Write), attribute.Name, attribute);
		}
		public int IndexOf (DirectoryAttributeModification value)
		{
			return List.IndexOf (value);
		}
Exemple #38
0
        public void AppendAttrValue(string attrName, string value)
        {
            CheckForDeletion();

            string propName = attrName.ToLowerInvariant();

            DirectoryAttributeModification dam;
            if (_changes.ContainsKey(propName))
            {
                dam = _changes[propName];

                if (this.ConflictMode == ConflictModes.Error && dam.Operation != DirectoryAttributeOperation.Add)
                {
                    throw new IncompatibleMutationException(
                        String.Format("Can't process a request to {0} and append on attr {1} - indeterminate results",
                            dam.Operation, propName));
                }
                else
                {
                    logger.Info("Request on attr {0} is {1}, but appending value {2} anyway",
                        propName, dam.Operation, value);

                    if (dam.Contains(""))
                    {
                        logger.Info("Removing empty-replacement value on {0}", propName);
                        dam.Remove("");
                    }

                    if (!dam.Contains(value))
                        dam.Add(value);
                }
            }
            else
            {
                dam = new DirectoryAttributeModification();
                dam.Name = propName;
                dam.Operation = DirectoryAttributeOperation.Add;
                dam.Add(value);
                _changes[propName] = dam;
            }
        }
		public void Remove (DirectoryAttributeModification value)
		{
			List.Remove (value);
		}
Exemple #40
0
        /// <summary>
        /// Establecer una nueva password para un usuario 
        /// </summary>
        /// <param name="UserLogin">Login del usuario</param>
        /// <param name="newPassword">Nueva contraseña</param>
        /// <returns></returns>
        public ResultCode SetPassword(string UserLogin, string newPassword)
        {
            if (!this.UserExist(UserLogin))
                return ResultCode.NoSuchObject;

            this.OpenConnection();
            DirectoryAttributeModification modOperation = new DirectoryAttributeModification();
            modOperation.Name = "unicodePwd";
            modOperation.Add(GetPasswordData(newPassword));
            modOperation.Operation = DirectoryAttributeOperation.Replace;

            string userDN = string.Format("CN={0},{1}", UserLogin, this._usersDistinguishedName);

            ModifyRequest request = new ModifyRequest(userDN, modOperation);

            DirectoryResponse response = this._adamConnection.SendRequest(request);
            this.CloseConnection();
            return response.ResultCode;
        }
Exemple #41
0
        /// <summary>
        /// Crear un nuevo usuario en el ADAM
        /// </summary>
        /// <param name="loginName">Nombre de Login</param>
        /// <param name="fullName">Nombre y Apellido del usuario</param>
        /// <param name="password">Contraseña</param>
        /// <returns></returns>
        public ResultCode CreateUser(string loginName, string fullName, string password)
        {
            if (this.UserExist(loginName))
                return ResultCode.EntryAlreadyExists;

            this.OpenConnection();

            string dirClasstype = "user";
            string userDN = string.Format("CN={0},{1}", loginName, this._usersDistinguishedName);
            AddRequest addNewUserRequest = new AddRequest(userDN, dirClasstype);
            AddResponse response = (AddResponse)this._adamConnection.SendRequest(addNewUserRequest);

            if (response.ResultCode != ResultCode.Success)
                return response.ResultCode;

            DirectoryAttributeModification attFullName = new DirectoryAttributeModification();
            attFullName.Name = "givenName";
            attFullName.Operation = DirectoryAttributeOperation.Add;
            attFullName.Add(fullName);

            DirectoryAttributeModification attPassword = new DirectoryAttributeModification();
            attPassword.Name = "unicodePwd";
            attPassword.Add(GetPasswordData(password));
            attPassword.Operation = DirectoryAttributeOperation.Add;

            DirectoryAttributeModification attDisableAccount = new DirectoryAttributeModification();
            attDisableAccount.Name = "msDS-UserAccountDisabled";
            attDisableAccount.Add("FALSE");
            attDisableAccount.Operation = DirectoryAttributeOperation.Replace;

            ModifyRequest modRequest = new ModifyRequest(userDN, attFullName, attPassword, attDisableAccount);
            ModifyResponse modResponse = (ModifyResponse)this._adamConnection.SendRequest(modRequest);
            if (modResponse.ResultCode != ResultCode.Success)
                return modResponse.ResultCode;

            this.CloseConnection();
            return modResponse.ResultCode;
        }
        public static bool SetPassword(LdapConnection connection, string userDN, string newPassword, bool dryRun = false)
        {
            DirectoryAttributeModification addMod = new DirectoryAttributeModification();
            addMod.Name = "unicodePwd";
            addMod.Add(Encoding.Unicode.GetBytes("\"" + newPassword + "\""));
            addMod.Operation = DirectoryAttributeOperation.Replace;
            ModifyRequest request = new ModifyRequest(userDN, addMod);

            try
            {
                if (!dryRun)
                {
                    DirectoryResponse response = connection.SendRequest(request);
                    return response.ResultCode == 0;
                }
                else
                {
                    return true;
                }
            }
            catch (DirectoryOperationException ex)
            {
                if (ex.Response.ErrorMessage.StartsWith("0000052D"))
                {
                    throw new Exception("Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirements of the domain.");
                }
                else
                {
                    throw;
                }
            }
        }
Exemple #43
0
        /// <summary>
        /// Replace all values of 'attrName' with the empty string.
        /// </summary>
        /// <param name="propName">The name of the property / attribute to clear</param>
        public void ClearAttr(string attrName)
        {
            CheckForDeletion();
            attrName = attrName.ToLowerInvariant();

            if (this.GetAttrValueCount(attrName) > 0)
            {
                DirectoryAttributeModification dam;
                if (_changes.ContainsKey(attrName))
                {
                    dam = _changes[attrName];
                    if (dam.Operation == DirectoryAttributeOperation.Replace)
                    {
                        if (dam.Count == 0)
                        {
                            logger.Debug("Already contains request to set {0} with Replace/Clear", attrName);
                            return;
                        }
                    }

                    if (this.ConflictMode == ConflictModes.Error)
                    {
                        throw new IncompatibleMutationException(String.Format(
                                "Change buffer already contains a non-blank request to modify attr {0} as {1}",
                                attrName, dam.Operation));
                    }
                    else
                    {
                        logger.Info("Overriding non-blank {0} request on attr {1} with Replace/Clear",
                            dam.Operation, attrName);


                        dam = new DirectoryAttributeModification() { Name = attrName, Operation = DirectoryAttributeOperation.Replace };
                        dam.Clear();
                        _changes[attrName] = dam;

                        /*
                        dam = new DirectoryAttributeModification() { Name = propName, Operation = DirectoryAttributeOperation.Delete };
                        _changes[propName] = dam;
                        */
                        if (_changes.ContainsKey(attrName + "*d"))
                        {
                            logger.Warn("Removing useless single-value deletion on attr {0}", attrName);
                            _changes.Remove(attrName + "*d");
                        }
                    }
                }
                else
                {
                    dam = new DirectoryAttributeModification() { Name = attrName, Operation = DirectoryAttributeOperation.Replace };
                    dam.Clear();
                    _changes[attrName] = dam;

                    logger.Debug("Set Replace/Clear on attr {0}", attrName);

                    if (_changes.ContainsKey(attrName + "*d"))
                    {
                        logger.Warn("Removing useless single-value deletion on attr {0}");
                        _changes.Remove(attrName + "*d");
                    }
                }
            }
        }
Exemple #44
-1
        public void SetPassword(string uname, string value)
        {
            string userDN = this.GetUserDN(uname);

            DirectoryAttributeModification mod = new DirectoryAttributeModification
            {
                Name = Settings.Store.LDAPPasswordAttribute,
                Operation = DirectoryAttributeOperation.Replace
            };
            mod.Add(value);

            ModifyRequest req = new ModifyRequest(userDN);
            req.Modifications.Add(mod);

            m_conn.SendRequest(req);
        }