[bugs] [Bug 1286] Changed - renaming an entry when using openLDAP 2.1.x fails to succeed.

bugs at bugs.horde.org bugs at bugs.horde.org
Tue Jun 17 12:54:38 PDT 2003


http://bugs.horde.org/show_bug.cgi?id=1286

*** shadow/1286	Tue Jun 17 16:50:23 2003
--- shadow/1286.tmp.18994	Tue Jun 17 16:54:38 2003
***************
*** 96,98 ****
--- 96,147 ----
           }
       }
  
+ 
+ ------- Additional Comments From urkle at drip.ws  06/17/03 16:54 -------
+ Patch for CVS HEAD
+ --- ldap.php.orig	Fri Jun 13 10:21:15 2003
+ +++ ldap.php	Tue Jun 17 14:53:07 2003
+ @@ -372,8 +372,23 @@
+                  }
+                  unset($attributes[$lowerkey]);
+              }
+ +	    if (isset($attributes[$lowerkey]) &&
+ + 		($var[0] != $attributes[$lowerkey]) &&
+ + 		$lowerkey == 'cn') {
+ + 		// OK we need to change the CN of the entry
+ + 		// so lets save the old and new name and rename it later
+ + 		$modrdn["olddn"] = $object_id;
+ + 		$modrdn["newdn"] = $attributes["cn"];
+ + 	    }
+          }
+  
+ +	//we can't change the CN (well not supposed to)
+ +	//older LDAP servers allow the CN attribute to be different than
+ +	//the entry in the DN. the LDAPv3 spec specifies that they have to
+ +	// be the same.. note there can be multiple cn entries. but one of 
+ +	// them HAS to be the entry in the DN.
+ +	unset($attributes["cn"]);
+ +
+          // Encode entries.
+          foreach ($attributes as $key => $val) {
+              if (!is_array($val)) {
+ @@ -389,6 +404,16 @@
+              $this->errstr = ldap_error($this->ds);
+              return false;
+          } else {
+ +	    // ok the modify passed now lets rename the DN if we need to
+ +	    if (isset($modrdn)) {
+ +		$modrdn['newroot'] = substr($modrdn['olddn'],strpos($modrdn['olddn'],",")+1);
+ +		$modrdn['newdn'] = "cn=".$modrdn['newdn'];
+ +		if
+ (!@ldap_rename($this->ds,$modrdn['olddn'],$modrdn['newdn'],$modrdn['newroot'],true))
+ {
+ +		    $this->errno = ldap_errno($this->ds);
+ +		    $this->errstr = ldap_error($this->ds);
+ +		    return false;
+ +		}
+ +	    }
+              return true;
+          }
+      }
+ 


More information about the bugs mailing list