From bbf7b81e17e77d201a506ccd3a9dbed382bc1624 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 20 Sep 2010 13:36:26 +0000 Subject: [PATCH] Updated character handling detection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19771 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 9 ++++++++- gosa-core/include/functions.inc | 21 ++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 68a94658d..db88defe2 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -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(); + } } diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 680416e1b..598a41baa 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -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']; -- 2.30.2