index 67921e0ba5565eb140520d50b3ee40baabe44f50..6af377218add9ef4562a5ccf76858426a92b4d81 100644 (file)
*/
function rename_dn($source,$dest)
{
+ $source = LDAP::fix($source);
+ $dest = LDAP::fix($dest);
+
+ /* Check if source and destination are the same entry */
+ if(strtolower($source) == strtolower($dest)){
+ trigger_error("Source and destination can't be the same entry.");
+ $this->error = "Source and destination can't be the same entry.";
+ return(FALSE);
+ }
+
+ /* Check if destination entry exists */
+ if($this->dn_exists($dest)){
+ trigger_error("Destination '$dest' already exists.");
+ $this->error = "Destination '$dest' already exists.";
+ return(FALSE);
+ }
+
/* Extract the name and the parent part out ouf source dn.
e.g. cn=herbert,ou=department,dc=...
- parent => ou=department,dc=...
- dest => cn=herbert
+ parent => ou=department,dc=...
+ dest_rdn => cn=herbert
*/
- $parent = preg_replace("/^[^,]+,/","",$dest);
- $dest = preg_replace("/,.*$/","",$dest);
+ $parent = preg_replace("/^[^,]+,/","",$dest);
+ $dest_rdn = preg_replace("/,.*$/","",$dest);
if($this->hascon){
if ($this->reconnect) $this->connect();
- $r= @ldap_rename($this->cid,$source,$dest,$parent,TRUE);
- $this->error = @ldap_error($this->cid);
- return(!$r ? $r : TRUE);
+ $r= ldap_rename($this->cid,$source,$dest_rdn,$parent,TRUE);
+ $this->error = ldap_error($this->cid);
+
+ /* Check if destination dn exists, if not the
+ server may not support this operation */
+ $r &= is_resource($this->dn_exists($dest));
+ return($r);
}else{
$this->error = "Could not connect to LDAP server";
return(FALSE);
}
# Get base to look for schema
- $sr = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
- if(!$sr){
- $sr = @ldap_read ($this->cid, "", "objectClass=*", array("subschemaSubentry"));
- }
-
+ $sr = @ldap_read ($this->cid, "", "objectClass=*", array("subschemaSubentry"));
$attr = @ldap_get_entries($this->cid,$sr);
if (!isset($attr[0]['subschemasubentry'][0])){
return array();
if(class_available("session")){
session::set("LDAP_CACHE::get_objectclasses",$objectclasses);
}
+
return $objectclasses;
}