X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_ldap.inc;h=f3baf144d8905d58dbe1322c9460fac2f860562e;hb=3654000069256d0fb3b4cbb31bd2bd5478f163f2;hp=2a0055bee7aa430756e8b230da21458903f3f859;hpb=85f173bfe6d1023d9cc7cb4679e351d113cb97be;p=gosa.git diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 2a0055bee..f3baf144d 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -81,19 +81,19 @@ class LDAP{ /* Function to replace all problematic characters inside a DN by \001XX, where \001 is decoded to chr(1) [ctrl+a]. It is not impossible, but very unlikely that this character is inside a DN. - + Currently used codes: - , => CO - \2C => CO - ( => OB - ) => CB - / => SL */ + , => CO + \2C => CO + ( => OB + ) => CB + / => SL */ static function convert($dn) { if (SPECIALS_OVERRIDE == TRUE){ $tmp= preg_replace(array("/\\\\,/", "/\\\\2C/", "/\(/", "/\)/", "/\//"), - array("\001CO", "\001CO", "\001OB", "\001CB", "\001SL"), - $dn); + array("\001CO", "\001CO", "\001OB", "\001CB", "\001SL"), + $dn); return (preg_replace('/,\s+/', ',', $tmp)); } else { return ($dn); @@ -109,19 +109,18 @@ class LDAP{ { if (SPECIALS_OVERRIDE == TRUE){ return (preg_replace(array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/"), - array("\,", "(", ")", "/"), - $dn)); + array("\,", "(", ")", "/"), + $dn)); } else { return ($dn); } } - /* Function to fix problematic characters in DN's that are used for search requests. I.e. member=.... */ static function prepare4filter($dn) { - return normalizeLdap(preg_replace('/\\\\/', '\\\\\\', LDAP::fix($dn))); + return normalizeLdap(str_replace('\\\\', '\\\\\\', LDAP::fix($dn))); } @@ -464,9 +463,6 @@ class LDAP{ */ 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."); @@ -486,12 +482,12 @@ class LDAP{ parent => ou=department,dc=... dest_rdn => cn=herbert */ - $parent = 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_rdn,$parent,TRUE); + $r= ldap_rename($this->cid,@LDAP::fix($source), @LDAP::fix($dest_rdn),@LDAP::fix($parent),TRUE); $this->error = ldap_error($this->cid); /* Check if destination dn exists, if not the @@ -622,7 +618,7 @@ class LDAP{ } else { $type= preg_replace('/^([^=]+)=.*$/', '\\1', $cdn); - $param= preg_replace('/^[^=]+=([^,]+),.*$/', '\\1', $cdn); + $param= preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn); $na= array(); @@ -706,6 +702,9 @@ class LDAP{ $this->add($na); if (!$this->success()){ + + print_a(array($cdn,$na)); + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($this->get_error(), $cdn, LDAP_ADD, get_class())); return FALSE; } @@ -1201,7 +1200,7 @@ class LDAP{ } - function get_objectclasses() + function get_objectclasses( $force_reload = FALSE) { $objectclasses = array(); global $config; @@ -1214,8 +1213,8 @@ class LDAP{ } /* Return the cached results. */ - if(class_available('session') && session::is_set("LDAP_CACHE::get_objectclasses")){ - $objectclasses = session::get("LDAP_CACHE::get_objectclasses"); + if(class_available('session') && session::global_is_set("LDAP_CACHE::get_objectclasses") && !$force_reload){ + $objectclasses = session::global_get("LDAP_CACHE::get_objectclasses"); return($objectclasses); } @@ -1278,7 +1277,7 @@ class LDAP{ } if(class_available("session")){ - session::set("LDAP_CACHE::get_objectclasses",$objectclasses); + session::global_set("LDAP_CACHE::get_objectclasses",$objectclasses); } return $objectclasses; @@ -1309,8 +1308,8 @@ class LDAP{ function log($string) { - if (session::is_set('config')){ - $cfg = session::get('config'); + if (session::global_is_set('config')){ + $cfg = session::global_get('config'); if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){ syslog (LOG_INFO, $string); }