Code

Updated character handling detection
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 20 Sep 2010 13:36:26 +0000 (13:36 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 20 Sep 2010 13:36:26 +0000 (13:36 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19771 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_ldap.inc
gosa-core/include/functions.inc

index 68a94658d8d8f606ded0db5fac0cedcc191fae88..db88defe203bc36f8b8eb1dbf2956b8b86f40137 100644 (file)
@@ -28,7 +28,9 @@ define("NO_FILE_UPLOADED",10003);
 define("INSERT_OK",10000);
 define("SPECIALS_OVERRIDE", TRUE);
 
-class LDAP{
+class LDAP
+{
+    public static $characterMap = NULL;
 
   var $hascon   =false;
   var $reconnect=false;
@@ -66,6 +68,11 @@ class LDAP{
     }
 
     $this->connect();
+
+    // Get detected character mapping
+    if(LDAP::$characterMap == NULL){
+        LDAP::$characterMap = detectLdapSpecialCharHandling();
+    }
   }
 
 
index 680416e1bd020c973af54622d3a81b596f66808e..598a41baa26ff7e49e3518b3771b6e6cef293bd2 100644 (file)
@@ -3804,31 +3804,30 @@ function detectLdapSpecialCharHandling()
 
     // Get ldap connection and check if we've already created the character 
     //  detection object. 
-    $ldap = $config->get_ldap_link();
-    $ldapCID = $ldap->cid();
-
-    $res = ldap_list($ldap->cid, $config->current['BASE'], "(&(o={$name})(objectClass=organization))",array('dn'));
-    $cnt = ldap_count_entries($ldap->cid, $res);
+    $ldapCID = @ldap_connect($config->current['SERVER']);
+    @ldap_bind($ldapCID, $config->current['ADMINDN'],$config->current['ADMINPASSWORD']);
+    $res = ldap_list($ldapCID, $config->current['BASE'], "(&(o={$name})(objectClass=organization))",array('dn'));
+    $cnt = ldap_count_entries($ldapCID, $res);
     if(!$cnt){
         $obj = array();
         $obj['objectClass'] = array('top','organization');
         $obj['o'] = $name;
         $obj['description'] = 'GOsa character encoding test-object.';
-        ldap_add($ldap->cid, $config->current['BASE'], $attrs);
+        ldap_add($ldapCID, $config->current['BASE'], $attrs);
     }
     
     
     // Read the encoding instruction set.
-    $res = ldap_list($ldap->cid, $config->current['BASE'], "(&(o={$name})(objectClass=organization))",array('*'));
-    $cnt = ldap_count_entries($ldap->cid, $res);
+    $res = ldap_list($ldapCID, $config->current['BASE'], "(&(o={$name})(objectClass=organization))",array('*'));
+    $cnt = ldap_count_entries($ldapCID, $res);
     if($cnt != 1){
         trigger_error("GOsa couldn't detect the special character encoding used by your ldap!");
         return(NULL);
     }else{
 
-        $re = ldap_first_entry($ldap->cid, $res);
-        $attrs= ldap_get_attributes($ldap->cid, $re);
-        $attrs['dn']= trim(ldap_get_dn($ldap->cid, $re));
+        $re = ldap_first_entry($ldapCID, $res);
+        $attrs= ldap_get_attributes($ldapCID, $re);
+        $attrs['dn']= trim(ldap_get_dn($ldapCID, $re));
     
         $o = $attrs['o'][0];
         $dn = $attrs['dn'];