Commit a4e0d1286104c8d382f64a803a838beebd1818ef

Authored by Etienne Pallier
1 parent 2730813c

back to old version

Showing 1 changed file with 27 additions and 6 deletions   Show diff stats
src/Model/Table/LdapConnectionsTable.php
... ... @@ -193,12 +193,18 @@ class LdapConnectionsTable extends AppTable
193 193  
194 194 if ($this->checkConfiguration()) {
195 195 if ($this->USE_LDAP) {
196   - /*
197 196 $ldapConnection = ldap_connect($this->host, $this->port);
198 197 ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
199   - */
200   - /* CRAL
201   - */
  198 + $results = ldap_search($ldapConnection, $this->baseDn, '(' . $this->authenticationType . '=' . $userName . ')');
  199 + return ldap_get_entries($ldapConnection, $results);
  200 + /*
  201 + if ($this->checkConfiguration()) {
  202 + if ($this->USE_LDAP) {
  203 + ///
  204 + $ldapConnection = ldap_connect($this->host, $this->port);
  205 + ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
  206 + ///
  207 + // CRAL
202 208 //$results = ldap_search($ldapConnection, $this->baseDn, $filter);
203 209 if ($LDAP_ANONYMOUS)
204 210 $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
207 213 $info = ldap_get_entries($ldapConnection, $results);
208 214 //echo $info["count"]." entries returned\n";
209 215 return $info;
  216 + */
210 217 } else
211 218 return array(
212 219 $this->getFakeLdapUser($userName)
... ... @@ -329,6 +336,19 @@ class LdapConnectionsTable extends AppTable
329 336 try {
330 337 if ($this->checkConfiguration()) {
331 338  
  339 + if ($this->USE_LDAP) {
  340 + if (strlen(trim($password)) == 0) return FALSE;
  341 + $ldapConnection = ldap_connect($this->host, $this->port);
  342 + ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
  343 + if (@ldap_bind($ldapConnection, $this->authenticationType . '=' . $user_login . ',' . $this->baseDn, $user_password)) {
  344 + return $this->getUserAttributes($user_login)[0];
  345 + /*
  346 + * } else {
  347 + * return false;
  348 + */
  349 + }
  350 +
  351 + /*
332 352 // We are using LDAP
333 353 if ($this->USE_LDAP) {
334 354 $LDAP_ANONYMOUS = true;
... ... @@ -371,12 +391,13 @@ class LdapConnectionsTable extends AppTable
371 391 //return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0];
372 392 $search = $this->getUserAttributes($user_login, $LDAP_ANONYMOUS, $filter, $just_these) or die("Could not search in LDAP server, response was: " . ldap_error($ldapConnection) );
373 393 return $search[0];
374   - /*
  394 + ///
375 395 * } else {
376 396 * return false;
377   - */
  397 + ///
378 398 }
379 399 }
  400 + */
380 401  
381 402 // We are not using LDAP (use FAKE LDAP instead)
382 403 } else {
... ...