Commit d2c77887c0fb153ccc0d2225fa3ce9dc3b39c559
1 parent
f37b9499
Exists in
master
and in
3 other branches
improved ldap errors checking
Showing
1 changed file
with
5 additions
and
3 deletions
Show diff stats
src/Model/Table/LdapConnectionsTable.php
... | ... | @@ -357,14 +357,16 @@ class LdapConnectionsTable extends AppTable |
357 | 357 | $binddn .= ','.$this->baseDn; |
358 | 358 | |
359 | 359 | // Connection |
360 | - $ldapConnection = ldap_connect($this->host, $this->port); | |
360 | + $ldapConnection = ldap_connect($this->host, $this->port) or die("Could not connect to $this->host (port $this->port)"); | |
361 | 361 | if ($ldapConnection) { |
362 | 362 | ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); |
363 | 363 | // Binding |
364 | 364 | //if (@ldap_bind($ldapConnection, $this->authenticationType . '=' . $login . ',' . $this->baseDn, $password)) { |
365 | - $ldapbind = ldap_bind($ldapConnection, $binddn, $ldappass); | |
365 | + $ldapbind = ldap_bind($ldapConnection, $binddn, $ldappass) or die( "Could not bind to LDAP server.". ldap_error($ldapConnection) ); | |
366 | 366 | if ($ldapbind) { |
367 | - return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0]; | |
367 | + //return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0]; | |
368 | + $search = $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these) or die("Could not search in LDAP server, response was: " . ldap_error($ldapConnection) ); | |
369 | + return $search[0]; | |
368 | 370 | /* |
369 | 371 | * } else { |
370 | 372 | * return false; | ... | ... |