Ajout pour débuggage ldap
This commit is contained in:
parent
0bd66a0837
commit
6a89ba4277
@ -219,7 +219,7 @@ class Ldap
|
|||||||
{
|
{
|
||||||
//$this->bind=???? Comment positionne-t-on bind avec activedirectory ?
|
//$this->bind=???? Comment positionne-t-on bind avec activedirectory ?
|
||||||
//si bind non défini, les autres fonctions échouent
|
//si bind non défini, les autres fonctions échouent
|
||||||
$connected=2;
|
$connected=3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -772,47 +772,53 @@ class Ldap
|
|||||||
*/
|
*/
|
||||||
function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0)
|
function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0)
|
||||||
{
|
{
|
||||||
$fulllist=array();
|
$fulllist=array();
|
||||||
|
|
||||||
dolibarr_syslog("Ldap::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".join(',',$attributeArray).")");
|
dolibarr_syslog("Ldap::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".join(',',$attributeArray).")");
|
||||||
|
|
||||||
// if the directory is AD, then bind first with the search user first
|
// if the directory is AD, then bind first with the search user first
|
||||||
if ($this->serverType == "activedirectory")
|
if ($this->serverType == "activedirectory")
|
||||||
{
|
{
|
||||||
$this->bindauth($this->searchUser, $this->searchPassword);
|
$this->bindauth($this->searchUser, $this->searchPassword);
|
||||||
dolibarr_syslog("Ldap::bindauth serverType=activedirectory searchUser=".$this->searchUser);
|
dolibarr_syslog("Ldap::bindauth serverType=activedirectory searchUser=".$this->searchUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define filter
|
// Define filter
|
||||||
if ($activefilter == 1)
|
if ($activefilter == 1)
|
||||||
{
|
{
|
||||||
if ($this->filter) $filter = '('.$this->filter.')';
|
if ($this->filter)
|
||||||
else $filter='('.$useridentifier.'=*)';
|
{
|
||||||
}
|
$filter = '('.$this->filter.')';
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
$filter = '('.$useridentifier.'='.$search.')';
|
{
|
||||||
}
|
$filter='('.$useridentifier.'=*)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filter = '('.$useridentifier.'='.$search.')';
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($attributeArray))
|
if (is_array($attributeArray))
|
||||||
{
|
{
|
||||||
// Return list with required fields
|
// Return list with required fields
|
||||||
dolibarr_syslog("Ldap::getRecords connection=".$this->connection." userDn=".$userDn." filter=".$filter. " attributeArray=(".join(',',$attributeArray).")");
|
dolibarr_syslog("Ldap::getRecords connection=".$this->connection." userDn=".$userDn." filter=".$filter. " attributeArray=(".join(',',$attributeArray).")");
|
||||||
$this->result = @ldap_search($this->connection, $userDn, $filter, $attributeArray);
|
$this->result = @ldap_search($this->connection, $userDn, $filter, $attributeArray);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Return list with fields selected by default
|
// Return list with fields selected by default
|
||||||
dolibarr_syslog("Ldap::getRecords connection=".$this->connection." userDn=".$userDn." filter=".$filter);
|
dolibarr_syslog("Ldap::getRecords connection=".$this->connection." userDn=".$userDn." filter=".$filter);
|
||||||
$this->result = @ldap_search($this->connection, $userDn, $filter);
|
$this->result = @ldap_search($this->connection, $userDn, $filter);
|
||||||
}
|
}
|
||||||
if (!$this->result)
|
if (!$this->result)
|
||||||
{
|
{
|
||||||
$this->error = 'LDAP search failed: '.ldap_errno($this->connection)." ".ldap_error($this->connection);
|
$this->error = 'LDAP search failed: '.ldap_errno($this->connection)." ".ldap_error($this->connection);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = @ldap_get_entries($this->connection, $this->result);
|
$info = @ldap_get_entries($this->connection, $this->result);
|
||||||
|
|
||||||
// Warning: Dans info, les noms d'attributs sont en minuscule meme si passé
|
// Warning: Dans info, les noms d'attributs sont en minuscule meme si passé
|
||||||
// a ldap_search en majuscule !!!
|
// a ldap_search en majuscule !!!
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user