From a9ebbd8fac9c4a4a94b16e0c90ba051d8d3696e5 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 14 Aug 2006 23:49:03 +0000
Subject: [PATCH] Update the modify processing code to ensure that attempts to add a new password value will check to ensure the new password doesn't match any password already in the user's entry.

---
 opends/src/server/org/opends/server/core/ModifyOperation.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/ModifyOperation.java b/opends/src/server/org/opends/server/core/ModifyOperation.java
index 5218672..556f7a3 100644
--- a/opends/src/server/org/opends/server/core/ModifyOperation.java
+++ b/opends/src/server/org/opends/server/core/ModifyOperation.java
@@ -1409,6 +1409,7 @@
             // password values (increment doesn't make any sense for passwords).
             // Then perform the appropriate type of processing for that kind of
             // modification.
+            boolean isAdd = false;
             LinkedHashSet<AttributeValue> pwValues = a.getValues();
             LinkedHashSet<AttributeValue> encodedValues =
                  new LinkedHashSet<AttributeValue>();
@@ -1421,6 +1422,7 @@
                 if (m.getModificationType() == ModificationType.ADD)
                 {
                   numPasswords += passwordsToAdd;
+                  isAdd = true;
                 }
                 else
                 {
@@ -1462,6 +1464,20 @@
                   }
                   else
                   {
+                    if (isAdd)
+                    {
+                      // Make sure that the password value doesn't already
+                      // exist.
+                      if (pwPolicyState.passwordMatches(v.getValue()))
+                      {
+                        setResultCode(ResultCode.ATTRIBUTE_OR_VALUE_EXISTS);
+
+                        int msgID = MSGID_MODIFY_PASSWORD_EXISTS;
+                        appendErrorMessage(getMessage(msgID));
+                        break modifyProcessing;
+                      }
+                    }
+
                     if (newPasswords == null)
                     {
                       newPasswords = new LinkedList<AttributeValue>();

--
Gitblit v1.10.0