Commit a4e0d1286104c8d382f64a803a838beebd1818ef
1 parent
2730813c
Exists in
master
and in
3 other branches
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,12 +193,18 @@ class LdapConnectionsTable extends AppTable | ||
193 | 193 | ||
194 | if ($this->checkConfiguration()) { | 194 | if ($this->checkConfiguration()) { |
195 | if ($this->USE_LDAP) { | 195 | if ($this->USE_LDAP) { |
196 | - /* | ||
197 | $ldapConnection = ldap_connect($this->host, $this->port); | 196 | $ldapConnection = ldap_connect($this->host, $this->port); |
198 | ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); | 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 | //$results = ldap_search($ldapConnection, $this->baseDn, $filter); | 208 | //$results = ldap_search($ldapConnection, $this->baseDn, $filter); |
203 | if ($LDAP_ANONYMOUS) | 209 | if ($LDAP_ANONYMOUS) |
204 | $results = ldap_search($ldapConnection, $this->baseDn, $filter) or die("Could not search to LDAP server response was: " . ldap_error($ldapConnection) ); | 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,6 +213,7 @@ class LdapConnectionsTable extends AppTable | ||
207 | $info = ldap_get_entries($ldapConnection, $results); | 213 | $info = ldap_get_entries($ldapConnection, $results); |
208 | //echo $info["count"]." entries returned\n"; | 214 | //echo $info["count"]." entries returned\n"; |
209 | return $info; | 215 | return $info; |
216 | + */ | ||
210 | } else | 217 | } else |
211 | return array( | 218 | return array( |
212 | $this->getFakeLdapUser($userName) | 219 | $this->getFakeLdapUser($userName) |
@@ -329,6 +336,19 @@ class LdapConnectionsTable extends AppTable | @@ -329,6 +336,19 @@ class LdapConnectionsTable extends AppTable | ||
329 | try { | 336 | try { |
330 | if ($this->checkConfiguration()) { | 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 | // We are using LDAP | 352 | // We are using LDAP |
333 | if ($this->USE_LDAP) { | 353 | if ($this->USE_LDAP) { |
334 | $LDAP_ANONYMOUS = true; | 354 | $LDAP_ANONYMOUS = true; |
@@ -371,12 +391,13 @@ class LdapConnectionsTable extends AppTable | @@ -371,12 +391,13 @@ class LdapConnectionsTable extends AppTable | ||
371 | //return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0]; | 391 | //return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0]; |
372 | $search = $this->getUserAttributes($user_login, $LDAP_ANONYMOUS, $filter, $just_these) or die("Could not search in LDAP server, response was: " . ldap_error($ldapConnection) ); | 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 | return $search[0]; | 393 | return $search[0]; |
374 | - /* | 394 | + /// |
375 | * } else { | 395 | * } else { |
376 | * return false; | 396 | * return false; |
377 | - */ | 397 | + /// |
378 | } | 398 | } |
379 | } | 399 | } |
400 | + */ | ||
380 | 401 | ||
381 | // We are not using LDAP (use FAKE LDAP instead) | 402 | // We are not using LDAP (use FAKE LDAP instead) |
382 | } else { | 403 | } else { |