Commit 1277e1a1dfdce8eec37573de8a179dcae352f37e

Authored by Etienne Pallier
1 parent a4e0d128

bugfix ldap anonymous

src/Model/Table/LdapConnectionsTable.php
... ... @@ -187,23 +187,24 @@ class LdapConnectionsTable extends AppTable
187 187 }
188 188  
189 189 // $userName = login
190   - public function getUserAttributes($userName, $LDAP_ANONYMOUS=true, $filter='', $just_these=[])
  190 + public function getUserAttributes($userName, $ldapConnection, $LDAP_ANONYMOUS=true, $filter='', $just_these=[])
191 191 {
192 192 try {
193 193  
  194 + /*
194 195 if ($this->checkConfiguration()) {
195 196 if ($this->USE_LDAP) {
196 197 $ldapConnection = ldap_connect($this->host, $this->port);
197 198 ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
198 199 $results = ldap_search($ldapConnection, $this->baseDn, '(' . $this->authenticationType . '=' . $userName . ')');
199 200 return ldap_get_entries($ldapConnection, $results);
200   - /*
  201 + */
201 202 if ($this->checkConfiguration()) {
202 203 if ($this->USE_LDAP) {
203   - ///
  204 + /*
204 205 $ldapConnection = ldap_connect($this->host, $this->port);
205 206 ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
206   - ///
  207 + */
207 208 // CRAL
208 209 //$results = ldap_search($ldapConnection, $this->baseDn, $filter);
209 210 if ($LDAP_ANONYMOUS)
... ... @@ -213,7 +214,6 @@ class LdapConnectionsTable extends AppTable
213 214 $info = ldap_get_entries($ldapConnection, $results);
214 215 //echo $info["count"]." entries returned\n";
215 216 return $info;
216   - */
217 217 } else
218 218 return array(
219 219 $this->getFakeLdapUser($userName)
... ... @@ -335,20 +335,15 @@ class LdapConnectionsTable extends AppTable
335 335 {
336 336 try {
337 337 if ($this->checkConfiguration()) {
338   -
  338 + /*
339 339 if ($this->USE_LDAP) {
340 340 if (strlen(trim($password)) == 0) return FALSE;
341 341 $ldapConnection = ldap_connect($this->host, $this->port);
342 342 ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
343 343 if (@ldap_bind($ldapConnection, $this->authenticationType . '=' . $user_login . ',' . $this->baseDn, $user_password)) {
344 344 return $this->getUserAttributes($user_login)[0];
345   - /*
346   - * } else {
347   - * return false;
348   - */
349 345 }
350   -
351   - /*
  346 + */
352 347 // We are using LDAP
353 348 if ($this->USE_LDAP) {
354 349 $LDAP_ANONYMOUS = true;
... ... @@ -389,15 +384,15 @@ class LdapConnectionsTable extends AppTable
389 384 $ldapbind = ldap_bind($ldapConnection, $binddn, $ldappass) or die( "Could not bind to LDAP server.". ldap_error($ldapConnection) );
390 385 if ($ldapbind) {
391 386 //return $this->getUserAttributes($login, $LDAP_ANONYMOUS, $filter, $just_these)[0];
392   - $search = $this->getUserAttributes($user_login, $LDAP_ANONYMOUS, $filter, $just_these) or die("Could not search in LDAP server, response was: " . ldap_error($ldapConnection) );
  387 + $search = $this->getUserAttributes($user_login, $ldapConnection, $LDAP_ANONYMOUS, $filter, $just_these);
  388 + if ($search === false) die("Could not get user attributes from LDAP server, response was: " . ldap_error($ldapConnection) );
393 389 return $search[0];
394   - ///
  390 + /*
395 391 * } else {
396 392 * return false;
397   - ///
  393 + */
398 394 }
399 395 }
400   - */
401 396  
402 397 // We are not using LDAP (use FAKE LDAP instead)
403 398 } else {
... ...
src/Template/Layout/default.ctp
... ... @@ -119,7 +119,7 @@ $cakeDescription = 'Labinvent 2';
119 119 </i></td>
120 120 <td id="version">
121 121 <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) -->
122   - <font color="black">VERSION 2.9.1.0 (14/12/2018)</font> <br /> <font
  122 + <font color="black">VERSION 2.9.1.1 (14/12/2018)</font> <br /> <font
123 123 color="black"><a
124 124 href="<?php
125 125  
... ...