index 2a0055bee7aa430756e8b230da21458903f3f859..29f82e7fcd4e460a4c7f41dc04c0aa81695cb9b6 100644 (file)
/* 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);
{
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)));
+ $fixed= normalizeLdap(str_replace('\\\\', '\\\\\\', LDAP::fix($dn)));
+ return str_replace('\\,', '\\\\,', $fixed);
}
*/
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.");
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
} else {
$type= preg_replace('/^([^=]+)=.*$/', '\\1', $cdn);
- $param= preg_replace('/^[^=]+=([^,]+),.*$/', '\\1', $cdn);
+ $param= preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn);
$na= array();
$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;
}
}
}
+
function get_attribute($dn, $name,$r_array=0)
{
$data= "";
}
}
}
- if($r_array==0)
- return ($data);
- else
- return ($info);
-
-
+ if($r_array==0) {
+ return ($data);
+ } else {
+ return ($info);
+ }
}
}
- function get_objectclasses()
+ function get_objectclasses( $force_reload = FALSE)
{
$objectclasses = array();
global $config;
}
/* 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);
}
}
if(class_available("session")){
- session::set("LDAP_CACHE::get_objectclasses",$objectclasses);
+ session::global_set("LDAP_CACHE::get_objectclasses",$objectclasses);
}
return $objectclasses;
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);
}