Skip to content
Snippets Groups Projects
Commit 611545d9 authored by Andreas Gohr's avatar Andreas Gohr Committed by GitHub
Browse files

Merge pull request #1700 from itsho/patch-1

added debug prints to better figure out when LDAP has search issues.
parents 97cf50cd 40017f0b
No related branches found
No related tags found
No related merge requests found
...@@ -183,7 +183,11 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin { ...@@ -183,7 +183,11 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin {
$info = array(); $info = array();
$info['user'] = $user; $info['user'] = $user;
$this->_debug('LDAP user to find: '.htmlspecialchars($info['user']), 0, __LINE__, __FILE__);
$info['server'] = $this->getConf('server'); $info['server'] = $this->getConf('server');
$this->_debug('LDAP Server: '.htmlspecialchars($info['server']), 0, __LINE__, __FILE__);
//get info for given user //get info for given user
$base = $this->_makeFilter($this->getConf('usertree'), $info); $base = $this->_makeFilter($this->getConf('usertree'), $info);
...@@ -193,16 +197,33 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin { ...@@ -193,16 +197,33 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin {
$filter = "(ObjectClass=*)"; $filter = "(ObjectClass=*)";
} }
$sr = $this->_ldapsearch($this->con, $base, $filter, $this->getConf('userscope')); $this->_debug('LDAP Filter: '.htmlspecialchars($filter), 0, __LINE__, __FILE__);
$result = @ldap_get_entries($this->con, $sr);
$this->_debug('LDAP user search: '.htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__); $this->_debug('LDAP user search: '.htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
$this->_debug('LDAP search at: '.htmlspecialchars($base.' '.$filter), 0, __LINE__, __FILE__); $this->_debug('LDAP search at: '.htmlspecialchars($base.' '.$filter), 0, __LINE__, __FILE__);
$sr = $this->_ldapsearch($this->con, $base, $filter, $this->getConf('userscope'));
// Don't accept more or less than one response
if(!is_array($result) || $result['count'] != 1) { $result = @ldap_get_entries($this->con, $sr);
return false; //user not found
// if result is not an array
if(!is_array($result)) {
// no objects found
$this->_debug('LDAP search returned non-array result: '.htmlspecialchars(print($result)), -1, __LINE__, __FILE__);
return false;
} }
// Don't accept more or less than one response
if ($result['count'] != 1) {
$this->_debug('LDAP search returned '.htmlspecialchars($result['count']).' results while it should return 1!', -1, __LINE__, __FILE__);
//for($i = 0; $i < $result["count"]; $i++) {
//$this->_debug('result: '.htmlspecialchars(print_r($result[$i])), 0, __LINE__, __FILE__);
//}
return false;
}
$this->_debug('LDAP search found single result !', 0, __LINE__, __FILE__);
$user_result = $result[0]; $user_result = $result[0];
ldap_free_result($sr); ldap_free_result($sr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment