Menu

#13 OpenLdap Auth

open
nobody
None
5
2012-09-14
2011-10-18
Anonymous
No

I noticed that the ldap return values are used as array indices which is incorrect as ldap names are case insensitive while array names are case sensitive.. Not sure, but this may be the cause of some users difficulties depending on ldap / AD version.... A quick patch / diff is as follows:

--- ldap.inc.php-original 2011-10-13 15:11:12.000000000 +0100
+++ ldap.inc.php-caseFixed 2011-10-18 14:47:50.000000000 +0100
@@ -38,6 +38,7 @@

function authenticate($login,$password) {
$result = false;
+
/ just to be sure /
$this->disconnect();
if ($this->connect()) {
@@ -57,23 +58,24 @@
return $result;
}

-
function userinfo($login) {
$result = array();
+
if ($this->connect() and $this->bind()) {
$r = @ldap_search($this->ds, $this->config['userdn'],
'(&('.$this->ufield.'='.$login.')(objectclass='.$this->config['userclass'].'))');
if ($r) {
$res = @ldap_get_entries($this->ds, $r);
/ associate user fields /;
- $res = $res[0];
+ $res = array_change_key_case($res[0]);

     foreach ($this->config['userfields'] as $n => $f) {
       if ($f == 'group_id') {
  • $result[$f] = $res[$n];
  • $result[$f] = $res[strtolower($n)];
    } else {
  • $result[$f] = $res[$n][0];
  • $result[$f] = $res[strtolower($n)][0];
    }
    +
    }
    }
    if ($this->config['type']!='AD') {
    @@ -119,8 +121,6 @@
    return $result;
    }

-

function groupinfo($group = '') {
$result = array();
if ($this->connect()) {

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.