From ce965c2ebc7489688583a07d2580cf711ce3ebc8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Dec 2006 17:18:58 +0000 Subject: [PATCH] =?UTF-8?q?Mise=20en=20place=20=E0=20nouveau=20du=20filtre?= =?UTF-8?q?=20de=20recherche=20ldap=20afin=20de=20pouvoir=20trier=20les=20?= =?UTF-8?q?r=E9sultats=20correction=20de=20diff=E9rents=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/ldap_users.php | 19 ++++++++++--------- htdocs/lib/ldap.class.php | 12 ++++++++++-- htdocs/user/fiche.php | 22 +++++++++++----------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 83f4e1d53aa..d249f64fbd7 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -52,6 +52,7 @@ if ($_GET["action"] == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$_POST["key"])) $error++; if (! dolibarr_set_const($db, 'LDAP_USER_DN',$_POST["user"])) $error++; + if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION',$_POST["filterconnection"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA',$_POST["fieldloginsamba"])) $error++; @@ -116,6 +117,15 @@ print ''.$langs->trans("LDAPUserDnExample").''; print ' '; print ''; +// Filtre +//Utilise pour filtrer la recherche +$var=!$var; +print ''.$langs->trans("LDAPFilterConnection").''; +print ''; +print ''.$langs->trans("LDAPFilterConnectionExample").''; +print ''; +print ''; + print ''; print '
'; print ''; @@ -127,15 +137,6 @@ print ''; print ''; print "\n"; -// Filtre -/* -$var=!$var; -print ''; -print ''; -*/ - // Common name $var=!$var; print '
'.$langs->trans("LDAPLdapMapping").''.$langs->trans("LDAPNamingAttribute").'
'.$langs->trans("LDAPFilterConnection").picto_required().''; -print ''; -print ''.$langs->trans("LDAPFilterConnectionExample").'
'.$langs->trans("LDAPFieldFullname").''; diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php index a2872c867b3..6377ea30d19 100644 --- a/htdocs/lib/ldap.class.php +++ b/htdocs/lib/ldap.class.php @@ -719,7 +719,7 @@ class Ldap * username. The search criteria is a standard LDAP query - * returns all * users. The $attributeArray variable contains the required user detail field names */ - function getUsers($search, $userDn, $useridentifier, $attributeArray) + function getUsers($search, $userDn, $useridentifier, $attributeArray, $activefilter=0) { $userslist=array(); @@ -730,7 +730,15 @@ class Ldap $this->bindauth($this->searchUser, $this->searchPassword); } - $filter = '('.$useridentifier.'='.$search.')'; + if ($activefilter == 1) + { + $filter = $this->filter; + } + else + { + $filter = '('.$useridentifier.'='.$search.')'; + } + $this->result = @ldap_search($this->connection, $userDn, $filter); if (!$this->result) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index dcfdc1dcd3c..d9fe387e8d8 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -332,13 +332,13 @@ if ($_POST["action"] == 'adduserldap') foreach ($ldapusers as $key => $attribute) { $ldap_nom = $attribute[$conf->global->LDAP_FIELD_NAME]; - $ldap_prenom = $attribute[$conf->global->LDAP_FIELD_NAME]; + $ldap_prenom = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME]; $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA]; - $ldap_phone = $attribute[$conf->global->LDAP_FIELD_LOGIN_PHONE]; - $ldap_fax = $attribute[$conf->global->LDAP_FIELD_LOGIN_FAX]; - $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_LOGIN_MOBILE]; - $ldap_mail = $attribute[$conf->global->LDAP_FIELD_LOGIN_MAIL]; - $ldap_sid = $attribute[$conf->global->LDAP_FIELD_LOGIN_SID]; + $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; + $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; + $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; + $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; + $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; } } } @@ -391,12 +391,12 @@ if (($action == 'create') || ($action == 'adduserldap')) if ($result >= 0) { $justthese=array($conf->global->LDAP_KEY_USERS, - $conf->global->LDAP_FIELD_FULLNAME, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN_SAMBA); + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN_SAMBA); - $ldapusers = $ldap->getUsers('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $justthese); + $ldapusers = $ldap->getUsers('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $justthese, 1); if (is_array($ldapusers)) { $liste=array();