Modification afin de récupérer le SID avec Active Directory

This commit is contained in:
Regis Houssin 2006-12-20 22:34:13 +00:00
parent 7ca14661d8
commit fdcbbfab70
3 changed files with 33 additions and 7 deletions

View File

@ -49,6 +49,9 @@ class Form
var $cache_conditions_paiements_libelle=array(); var $cache_conditions_paiements_libelle=array();
var $tva_taux; var $tva_taux;
var $samaccountname;
/** /**
\brief Constructeur \brief Constructeur
\param DB handler d'accès base de donnée \param DB handler d'accès base de donnée
@ -2866,8 +2869,6 @@ class Form
else else
{ {
print utf8_decode("$val"); print utf8_decode("$val");
//print $val;
//print "<br>\n";
print '</td></tr>'; print '</td></tr>';
} }
} }

View File

@ -800,10 +800,22 @@ class Ldap
*/ */
function getObjectSid($ldapUser) function getObjectSid($ldapUser)
{ {
$criteria = $this->getUserIdentifier()."=$ldapUser"; $criteria = '('.$this->getUserIdentifier().'='.$ldapUser.')';
$justthese = array("objectsid"); $justthese = array("objectsid");
$ldapSearchResult = ldap_search($this->connection, $this->people, $criteria, $justthese); // if the directory is AD, then bind first with the search user first
if ($this->serverType == "activedirectory")
{
$this->bindauth($this->searchUser, $this->searchPassword);
}
$ldapSearchResult = @ldap_search($this->connection, $this->people, $criteria, $justthese);
if (!$ldapSearchResult)
{
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
return -1;
}
$entry = ldap_first_entry($this->connection, $ldapSearchResult); $entry = ldap_first_entry($this->connection, $ldapSearchResult);
$ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid"); $ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid");

View File

@ -131,6 +131,19 @@ else
} }
print '</tr>'; print '</tr>';
if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
{
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0)
{
$userSID = $ldap->getObjectSid($fuser->login);
}
print '<tr><td width="25%" valign="top">'.$langs->trans("SID").'</td>';
print '<td>'.$userSID.'</td>';
print "</tr>\n";
}
$langs->load("admin"); $langs->load("admin");
// LDAP DN // LDAP DN