diff --git a/src/Model/Table/LdapConnectionsTable.php b/src/Model/Table/LdapConnectionsTable.php index b9299ad..2ff14d5 100755 --- a/src/Model/Table/LdapConnectionsTable.php +++ b/src/Model/Table/LdapConnectionsTable.php @@ -193,12 +193,18 @@ class LdapConnectionsTable extends AppTable if ($this->checkConfiguration()) { if ($this->USE_LDAP) { - /* $ldapConnection = ldap_connect($this->host, $this->port); ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); - */ - /* CRAL - */ + $results = ldap_search($ldapConnection, $this->baseDn, '(' . $this->authenticationType . '=' . $userName . ')'); + return ldap_get_entries($ldapConnection, $results); + /* + if ($this->checkConfiguration()) { + if ($this->USE_LDAP) { + /// + $ldapConnection = ldap_connect($this->host, $this->port); + ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); + /// + // CRAL //$results = ldap_search($ldapConnection, $this->baseDn, $filter); if ($LDAP_ANONYMOUS) $results = ldap_search($ldapConnection, $this->baseDn, $filter) or die("Could not search to LDAP server response was: " . ldap_error($ldapConnection) ); @@ -207,6 +213,7 @@ class LdapConnectionsTable extends AppTable $info = ldap_get_entries($ldapConnection, $results); //echo $info["count"]." entries returned\n"; return $info; + */ } else return array( $this->getFakeLdapUser($userName) @@ -329,6 +336,19 @@ class LdapConnectionsTable extends AppTable try { if ($this->checkConfiguration()) { + if ($this->USE_LDAP) { + if (strlen(trim($password)) == 0) return FALSE; + $ldapConnection = ldap_connect($this->host, $this->port); + ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); + if (@ldap_bind($ldapConnection, $this->authenticationType . '=' . $user_login . ',' . $this->baseDn, $user_password)) { + return $this->getUserAttributes($user_login)[0]; + /* + * } else { + * return false; + */ + } + + /* // We are using LDAP if ($this->USE_LDAP) { $LDAP_ANONYMOUS = true; @@ -371,12 +391,13 @@ class LdapConnectionsTable extends AppTable //return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0]; $search = $this->getUserAttributes($user_login, $LDAP_ANONYMOUS, $filter, $just_these) or die("Could not search in LDAP server, response was: " . ldap_error($ldapConnection) ); return $search[0]; - /* + /// * } else { * return false; - */ + /// } } + */ // We are not using LDAP (use FAKE LDAP instead) } else { -- libgit2 0.21.2