index 8aa793cf1125952f874194a2b039c73393ce72ad..f3baf144d8905d58dbe1322c9460fac2f860562e 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){
- return preg_replace('/,\s+/', ',', str_replace(array('\\\\,', '\\\\2C', '\(/', '/\)', '\/'),
- array("\001CO", "\001CO", "\001OB", "\001CB", "\001SL"), $dn));
+ if (SPECIALS_OVERRIDE == TRUE){
+ $tmp= preg_replace(array("/\\\\,/", "/\\\\2C/", "/\(/", "/\)/", "/\//"),
+ array("\001CO", "\001CO", "\001OB", "\001CB", "\001SL"),
+ $dn);
+ return (preg_replace('/,\s+/', ',', $tmp));
} else {
return ($dn);
}
servers seem to take it the correct way. */
static function fix($dn)
{
- if (SPECIALS_OVERRIDE === TRUE){
- return (str_replace(array('\001CO', '\001OB', '\001CB', '\001SL'),
- array('\,', '(', ')', '/'), $dn));
+ if (SPECIALS_OVERRIDE == TRUE){
+ return (preg_replace(array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/"),
+ 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)));
}
*/
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_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);
}