From b3d2c175e94a18b37de63d6bc280d54ca2bc293e Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 21 Sep 2010 07:00:00 +0000 Subject: [PATCH] Updated ldap special character handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19777 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 9 ++++++--- gosa-core/include/functions.inc | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index f955eb09a..5c8bac1fb 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -117,17 +117,20 @@ class LDAP LDAP::$characterMapRegFrom = array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/", "/\001DQ/"); LDAP::$characterMapRegTo = array("\,", "(", ")", "/", '\"'); - if(LDAP::$characterMap == NULL){ + if(LDAP::$characterMap === NULL){ LDAP::$characterMap = detectLdapSpecialCharHandling(); // Check if character-detection was successfull, if it wasn't use a fallback. - if(LDAP::$characterMap){ + if(LDAP::$characterMap !== NULL){ LDAP::$characterMapRegFrom = array(); LDAP::$characterMapRegTo = array(); foreach(LDAP::$characterMap as $from => $to){ LDAP::$characterMapRegFrom[] = "/{$from}/"; LDAP::$characterMapRegTo[] = "/{$to}/"; } + }else{ + // To avoid querying a hundred times without any success, stop here. + LDAP::$characterMap = array(); } } @@ -148,7 +151,7 @@ class LDAP if (SPECIALS_OVERRIDE == TRUE){ // Update the conversion instruction set. - if(LDAP::$characterMap == NULL) LDAP::updateSpecialCharHandling(); + if(LDAP::$characterMap === NULL) LDAP::updateSpecialCharHandling(); return (preg_replace(LDAP::$characterMapRegFrom,LDAP::$characterMapRegTo,$dn)); } else { diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 9e0219e57..1b707a6ca 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -3818,7 +3818,10 @@ function detectLdapSpecialCharHandling() $obj['objectClass'] = array('top','organization'); $obj['o'] = $name; $obj['description'] = 'GOsa character encoding test-object.'; - ldap_add($ldapCID, $oDN, $obj); + if(!@ldap_add($ldapCID, $oDN, $obj)){ + trigger_error("GOsa couldn't detect the special character handling used by your ldap!"); + return(NULL); + } } // Read the character-handling detection entry from the ldap. @@ -3826,7 +3829,7 @@ function detectLdapSpecialCharHandling() "(&(o=".$filterName.")(objectClass=organization))", array('dn','o')); $cnt = ldap_count_entries($ldapCID, $res); - if($cnt != 1){ + if($cnt != 1 || !$res){ trigger_error("GOsa couldn't detect the special character handling used by your ldap!"); return(NULL); }else{ -- 2.30.2