diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 5577c3a15e2..fcb8f077ef8 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -62,6 +62,7 @@ if ($_GET["action"] == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"])) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',$_POST["fielddescription"])) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',$_POST["fieldsid"])) $error++; if ($error) { @@ -209,6 +210,14 @@ print '
| '; + $ldap = new Ldap(); - - if ($ldap->connect()) + $result = $ldap->connect_bind(); + if ($result >= 0) { - $bind=''; - if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) - { - dolibarr_syslog("user/fiche.php authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG); - $bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); - } - else - { - dolibarr_syslog("user/fiche.php bind",LOG_DEBUG); - $bind=$ldap->bind(); - } - if ($bind) - { - $justthese = array($fullname, $name, $firstname, $login); - $ldapusers = $ldap->getUsers('*', $justthese); - - //print "eee".$justthese." r ".$ldapusers; - //print_r($justthese); + $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); + $ldapusers = $ldap->getUsers('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $justthese); + if (is_array($ldapusers)) + { + $liste=array(); foreach ($ldapusers as $key => $ldapuser) { - if ($ldapuser[$login]) + $record=''; + foreach ($justthese as $value) { - if ($ldapuser[$name] != "") $liste[$ldapuser[$login]] = trim($ldapuser[$name]." ".$ldapuser[$firstname]); - else if ($ldapuser[$fullname] != "") $liste[$ldapuser[$login]] = $ldapuser[$fullname]; + if ($value) + { + $record.=$value."=".$ldapuser[$value]." "; + } } + $liste[$key] = $record; } - + print ' |