[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:50:23 PDT 2003


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

*** shadow/1286	Tue Jun 17 16:50:15 2003
--- shadow/1286.tmp.18738	Tue Jun 17 16:50:23 2003
***************
*** 47,49 ****
--- 47,98 ----
  sn: Doe
  mail: jane at example.com
  ---
+ 
+ ------- Additional Comments From urkle at drip.ws  06/17/03 16:50 -------
+ Turba 1.2 Patch
+ --- ldap.php.orig	Tue Feb 25 20:40:48 2003
+ +++ ldap.php	Tue Jun 17 01:45:42 2003
+ @@ -373,7 +373,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"];
+ + 		// lets mod the sn as well just to make things "neat"
+ + 		$attributes["sn"] = substr($attributes["cn"],strrpos($attributes["cn"]," ")+1);
+ + 	    }
+          }
+ + 	//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 in UTF-8 if requested.
+          if ($this->encoding == 'utf8') {
+ @@ -392,6 +408,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