Completed
Push — master ( 081a8a...911a15 )
by Yannick
52:03 queued 22:58
created
main/auth/ldap/authldap.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
     // res=-1 -> the user does not exist in the ldap database
79 79
     // res=1 -> invalid password (user does exist)
80 80
 
81
-    if ($res==1) { //WRONG PASSWORD
81
+    if ($res == 1) { //WRONG PASSWORD
82 82
         //$errorMessage = "LDAP User or password incorrect, try again.<br />";
83 83
         if (isset($log)) unset($log); if (isset($uid)) unset($uid);
84 84
         $loginLdapSucces = false;
85 85
     }
86
-    if ($res==-1) { //WRONG USERNAME
86
+    if ($res == -1) { //WRONG USERNAME
87 87
         //$errorMessage =  "LDAP User or password incorrect, try again.<br />";
88 88
         $login_ldap_success = false;
89 89
     }
90
-    if ($res==0) { //LOGIN & PASSWORD OK - SUCCES
90
+    if ($res == 0) { //LOGIN & PASSWORD OK - SUCCES
91 91
         //$errorMessage = "Successful login w/ LDAP.<br>";
92 92
         $login_ldap_success = true;
93 93
     }
@@ -103,30 +103,30 @@  discard block
 block discarded – undo
103 103
  *    @author Stefan De Wannemacker
104 104
  *    @author Roan Embrechts
105 105
  */
106
-function ldap_find_user_info ($login) {
106
+function ldap_find_user_info($login) {
107 107
     //error_log('Entering ldap_find_user_info('.$login.')',0);
108 108
     global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn;
109 109
     // basic sequence with LDAP is connect, bind, search,
110 110
     // interpret search result, close connection
111 111
 
112 112
     //echo "Connecting ...";
113
-    $ldap_connect = ldap_connect( $ldap_host, $ldap_port);
113
+    $ldap_connect = ldap_connect($ldap_host, $ldap_port);
114 114
     ldap_set_version($ldap_connect);
115 115
     if ($ldap_connect) {
116 116
         //echo " Connect to LDAP server successful ";
117 117
         //echo "Binding ...";
118 118
         $ldap_bind = false;
119
-        $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind);
119
+        $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind);
120 120
         if ($ldap_bind_res) {
121 121
             //echo " LDAP bind successful... ";
122 122
             //echo " Searching for uid... ";
123 123
             // Search surname entry
124 124
             //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login");
125 125
             //echo "<p> ldapDc = '$LDAPbasedn' </p>";
126
-            if(!empty($ldap_search_dn)) {
127
-                $sr=ldap_search($ldap_connect, $ldap_search_dn, "uid=$login");
126
+            if (!empty($ldap_search_dn)) {
127
+                $sr = ldap_search($ldap_connect, $ldap_search_dn, "uid=$login");
128 128
             } else {
129
-                $sr=ldap_search($ldap_connect, $ldap_basedn, "uid=$login");
129
+                $sr = ldap_search($ldap_connect, $ldap_basedn, "uid=$login");
130 130
             }
131 131
             //echo " Search result is ".$sr;
132 132
             //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr);
@@ -177,25 +177,25 @@  discard block
 block discarded – undo
177 177
     $password1  = $ldap_pass_placeholder;
178 178
     $official_code = '';
179 179
 
180
-    define ("STUDENT",5);
181
-    define ("COURSEMANAGER",1);
180
+    define("STUDENT", 5);
181
+    define("COURSEMANAGER", 1);
182 182
 
183 183
     $tutor_field = api_get_setting('ldap_filled_tutor_field');
184 184
     $tutor_value = api_get_setting('ldap_filled_tutor_field_value');
185
-    if(empty($tutor_field)) {
185
+    if (empty($tutor_field)) {
186 186
         $status = STUDENT;
187 187
     } else {
188
-        if(empty($tutor_value)) {
188
+        if (empty($tutor_value)) {
189 189
             //in this case, we are assuming that the admin didn't give a criteria
190 190
             // so that if the field is not empty, it is a tutor
191
-            if(!empty($info_array[$tutor_field])) {
191
+            if (!empty($info_array[$tutor_field])) {
192 192
                 $status = COURSEMANAGER;
193 193
             } else {
194 194
                 $status = STUDENT;
195 195
             }
196 196
         } else {
197 197
             //the tutor_value is filled, so we need to check the contents of the LDAP field
198
-            if (is_array($info_array[$tutor_field]) && in_array($tutor_value,$info_array[$tutor_field])) {
198
+            if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) {
199 199
                 $status = COURSEMANAGER;
200 200
             } else {
201 201
                 $status = STUDENT;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     if (empty($language)) { $language = 'english'; }
213 213
     $_userId = UserManager::create_user($prenom, $nom, $status,
214 214
                      $email, $uname, $password, $official_code,
215
-                     $language,'', '', 'ldap');
215
+                     $language, '', '', 'ldap');
216 216
 
217 217
     //echo "new user added to Chamilo, id = $_userId";
218 218
 
@@ -246,58 +246,58 @@  discard block
 block discarded – undo
246 246
  * @param string password given by user
247 247
  * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP
248 248
  */
249
-function ldap_authentication_check ($uname, $passwd) {
249
+function ldap_authentication_check($uname, $passwd) {
250 250
     //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0);
251
-    global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass;
251
+    global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2, $ldap_rdn, $ldap_pass;
252 252
     //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0);
253 253
     // Establish anonymous connection with LDAP server
254 254
     // Etablissement de la connexion anonyme avec le serveur LDAP
255
-    $ds=ldap_connect($ldap_host,$ldap_port);
255
+    $ds = ldap_connect($ldap_host, $ldap_port);
256 256
     ldap_set_version($ds);
257 257
 
258 258
     $test_bind = false;
259
-    $test_bind_res = ldap_handle_bind($ds,$test_bind);
259
+    $test_bind_res = ldap_handle_bind($ds, $test_bind);
260 260
     //if problem, use the replica
261
-    if ($test_bind_res===false) {
262
-        $ds=ldap_connect($ldap_host2,$ldap_port2);
261
+    if ($test_bind_res === false) {
262
+        $ds = ldap_connect($ldap_host2, $ldap_port2);
263 263
         ldap_set_version($ds);
264 264
     } else {
265 265
         //error_log('Connected to server '.$ldap_host);
266 266
     }
267
-    if ($ds!==false) {
267
+    if ($ds !== false) {
268 268
         //Creation of filter containing values input by the user
269 269
         // Here it might be necessary to use $filter="(samaccountName=$uname)"; - see http://support.chamilo.org/issues/4675
270
-        $filter="(uid=$uname)";
270
+        $filter = "(uid=$uname)";
271 271
         // Open anonymous LDAP connection
272
-        $result=false;
273
-        $ldap_bind_res = ldap_handle_bind($ds,$result);
272
+        $result = false;
273
+        $ldap_bind_res = ldap_handle_bind($ds, $result);
274 274
 	// Executing the search with the $filter parametr
275 275
         //error_log('Searching for '.$filter.' on LDAP server',0);
276
-        $sr=ldap_search($ds,$ldap_basedn,$filter);
276
+        $sr = ldap_search($ds, $ldap_basedn, $filter);
277 277
         $info = ldap_get_entries($ds, $sr);
278
-        $dn=($info[0]["dn"]);
278
+        $dn = ($info[0]["dn"]);
279 279
         // debug !!    echo"<br> dn = $dn<br> pass = $passwd<br>";
280 280
         // closing 1st connection
281 281
         ldap_close($ds);
282 282
     }
283 283
 
284 284
     // test the Distinguish Name from the 1st connection
285
-    if ($dn=="") {
286
-        return (-1);        // doesn't belong to the addressbook
285
+    if ($dn == "") {
286
+        return (-1); // doesn't belong to the addressbook
287 287
     }
288 288
     //bug ldap.. if password empty, return 1!
289
-    if ($passwd=="") {
289
+    if ($passwd == "") {
290 290
         return(1);
291 291
     }
292 292
     // Opening 2nd LDAP connection : Connection user for password check
293
-    $ds=ldap_connect($ldap_host,$ldap_port);
293
+    $ds = ldap_connect($ldap_host, $ldap_port);
294 294
     ldap_set_version($ds);
295 295
     if (!$test_bind) {
296
-        $ds=ldap_connect($ldap_host2,$ldap_port2);
296
+        $ds = ldap_connect($ldap_host2, $ldap_port2);
297 297
         ldap_set_version($ds);
298 298
     }
299 299
     // return in case of wrong password connection error
300
-    if (@ldap_bind( $ds, $dn , $passwd) === false) {
300
+    if (@ldap_bind($ds, $dn, $passwd) === false) {
301 301
         return (1); // invalid password
302 302
     } else {// connection successfull
303 303
         return (0);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 function ldap_set_version(&$resource) {
312 312
     //error_log('Entering ldap_set_version(&$resource)',0);
313 313
     global $ldap_version;
314
-    if ($ldap_version>2) {
314
+    if ($ldap_version > 2) {
315 315
         if (ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3)) {
316 316
             //ok - don't do anything
317 317
         } else {
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
  * @param boolean $ldap_bind
327 327
  * @return    boolean        Status of the bind assignment. True for success, false for failure.
328 328
  */
329
-function ldap_handle_bind(&$ldap_handler,&$ldap_bind) {
329
+function ldap_handle_bind(&$ldap_handler, &$ldap_bind) {
330 330
     //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0);
331
-    global $ldap_rdn,$ldap_pass, $extldap_config;
331
+    global $ldap_rdn, $ldap_pass, $extldap_config;
332 332
     $ldap_rdn = $extldap_config['admin_dn'];
333 333
     $ldap_pass = $extldap_config['admin_password'];
334 334
     if (!empty($ldap_rdn) and !empty($ldap_pass)) {
335 335
         //error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0);
336
-        $ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass);
336
+        $ldap_bind = ldap_bind($ldap_handler, $ldap_rdn, $ldap_pass);
337 337
         if (!$ldap_bind) {
338 338
             //error_log('Authenticated login failed',0);
339 339
             //try in anonymous mode, you never know...
@@ -359,40 +359,40 @@  discard block
 block discarded – undo
359 359
 
360 360
     global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance;
361 361
 
362
-    $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): '';
362
+    $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])) : '';
363 363
     $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : '';
364 364
     $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : '';
365 365
     $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : '';
366 366
 
367
-    $ldap_query=array();
367
+    $ldap_query = array();
368 368
 
369 369
     if ($keyword_username != "") {
370 370
         $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn);
371 371
     } else {
372
-        if ($keyword_lastname!=""){
373
-            $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
372
+        if ($keyword_lastname != "") {
373
+            $ldap_query[] = "(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
374 374
         }
375
-        if ($keyword_firstname!="") {
376
-            $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
375
+        if ($keyword_firstname != "") {
376
+            $ldap_query[] = "(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
377 377
         }
378 378
     }
379
-    if ($keyword_type !="" && $keyword_type !="all") {
380
-        $ldap_query[]="(employeeType=".$keyword_type.")";
379
+    if ($keyword_type != "" && $keyword_type != "all") {
380
+        $ldap_query[] = "(employeeType=".$keyword_type.")";
381 381
     }
382 382
 
383
-    if (count($ldap_query)>1){
384
-        $str_query.="(& ";
385
-        foreach ($ldap_query as $query){
386
-            $str_query.=" $query";
383
+    if (count($ldap_query) > 1) {
384
+        $str_query .= "(& ";
385
+        foreach ($ldap_query as $query) {
386
+            $str_query .= " $query";
387 387
         }
388
-        $str_query.=" )";
388
+        $str_query .= " )";
389 389
     } else {
390
-        $str_query= count($ldap_query) > 0 ? "(".$ldap_query[0].")" : null;
390
+        $str_query = count($ldap_query) > 0 ? "(".$ldap_query[0].")" : null;
391 391
     }
392 392
 
393 393
     $ds = ldap_connect($ldap_host, $ldap_port);
394 394
     ldap_set_version($ds);
395
-    if ($ds && count($ldap_query)>0) {
395
+    if ($ds && count($ldap_query) > 0) {
396 396
         $r = false;
397 397
         $res = ldap_handle_bind($ds, $r);
398 398
         //$sr = ldap_search($ds, "ou=test-ou,$ldap_basedn", $str_query);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
         return $info;
403 403
 
404 404
     } else {
405
-        if (count($ldap_query)!=0)
405
+        if (count($ldap_query) != 0)
406 406
             Display :: display_error_message(get_lang('LDAPConnectionError'));
407 407
         return array();
408 408
     }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function ldap_get_number_of_users() {
417 417
     $info = ldap_get_users();
418
-    if (count($info)>0) {
418
+    if (count($info) > 0) {
419 419
         return $info['count'];
420 420
     } else {
421 421
         return 0;
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
     $is_western_name_order = api_is_western_name_order();
436 436
     if (isset($_GET['submit'])) {
437 437
         $info = ldap_get_users();
438
-        if ($info['count']>0) {
439
-            for ($key = 0; $key < $info["count"]; $key ++) {
440
-                $user=array();
438
+        if ($info['count'] > 0) {
439
+            for ($key = 0; $key < $info["count"]; $key++) {
440
+                $user = array();
441 441
                 // Get uid from dn
442 442
                 //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in
443 443
                 //the corresponding index of the array
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
  * @return string Some HTML-code with modify-buttons
472 472
  * @author    Mustapha Alouani
473 473
  */
474
-function modify_filter($user_id,$url_params, $row) {
475
-    $query_string="id[]=".$row[0];
476
-    if (!empty($_GET['id_session'])){
474
+function modify_filter($user_id, $url_params, $row) {
475
+    $query_string = "id[]=".$row[0];
476
+    if (!empty($_GET['id_session'])) {
477 477
         $query_string .= '&amp;id_session='.Security::remove_XSS($_GET['id_session']);
478 478
     }
479 479
     //$url_params_id="id=".$row[0];
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8');
499 499
     $email = $data['mail'][0];
500 500
     // Get uid from dn
501
-    $dn_array=ldap_explode_dn($data['dn'],1);
501
+    $dn_array = ldap_explode_dn($data['dn'], 1);
502 502
     $username = $dn_array[0]; // uid is first key
503 503
     $outab[] = $data['edupersonprimaryaffiliation'][0]; // Here, "student"
504 504
     //$val = ldap_get_values_len($ds, $entry, "userPassword");
@@ -506,29 +506,29 @@  discard block
 block discarded – undo
506 506
     //$password = $val[0];
507 507
     // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
508 508
     $password = $data['userPassword'][0];
509
-    $structure=$data['edupersonprimaryorgunitdn'][0];
510
-    $array_structure=explode(",", $structure);
511
-    $array_val=explode("=", $array_structure[0]);
512
-    $etape=$array_val[1];
513
-    $array_val=explode("=", $array_structure[1]);
514
-    $annee=$array_val[1];
509
+    $structure = $data['edupersonprimaryorgunitdn'][0];
510
+    $array_structure = explode(",", $structure);
511
+    $array_val = explode("=", $array_structure[0]);
512
+    $etape = $array_val[1];
513
+    $array_val = explode("=", $array_structure[1]);
514
+    $annee = $array_val[1];
515 515
     // To ease management, we add the step-year (etape-annee) code
516
-    $official_code=$etape."-".$annee;
517
-    $auth_source='ldap';
516
+    $official_code = $etape."-".$annee;
517
+    $auth_source = 'ldap';
518 518
     // No expiration date for students (recover from LDAP's shadow expiry)
519
-    $expiration_date='';
520
-    $active=1;
521
-    if(empty($status)){$status = 5;}
522
-    if(empty($phone)){$phone = '';}
523
-    if(empty($picture_uri)){$picture_uri = '';}
519
+    $expiration_date = '';
520
+    $active = 1;
521
+    if (empty($status)) {$status = 5; }
522
+    if (empty($phone)) {$phone = ''; }
523
+    if (empty($picture_uri)) {$picture_uri = ''; }
524 524
     // Adding user
525 525
     $user_id = 0;
526 526
     if (UserManager::is_username_available($username)) {
527
-        $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
527
+        $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
528 528
     } else {
529 529
         if ($update_if_exists) {
530 530
             $user = api_get_user_info($username);
531
-            $user_id=$user['user_id'];
531
+            $user_id = $user['user_id'];
532 532
             UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
533 533
         }
534 534
     }
@@ -545,21 +545,21 @@  discard block
 block discarded – undo
545 545
 
546 546
     // Database Table Definitions
547 547
     $tbl_session                        = Database::get_main_table(TABLE_MAIN_SESSION);
548
-    $tbl_session_rel_class                = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
548
+    $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
549 549
     $tbl_session_rel_course                = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
550 550
     $tbl_session_rel_course_rel_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
551 551
     $tbl_course                            = Database::get_main_table(TABLE_MAIN_COURSE);
552 552
     $tbl_user                            = Database::get_main_table(TABLE_MAIN_USER);
553 553
     $tbl_session_rel_user                = Database::get_main_table(TABLE_MAIN_SESSION_USER);
554
-    $tbl_class                            = Database::get_main_table(TABLE_MAIN_CLASS);
555
-    $tbl_class_user                        = Database::get_main_table(TABLE_MAIN_CLASS_USER);
554
+    $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
555
+    $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
556 556
 
557 557
     $id_session = (int) $id_session;
558 558
     // Once users are imported in the users base, we can assign them to the session
559
-    $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'");
560
-    $CourseList=array();
561
-    while ($row=Database::fetch_array($result)) {
562
-        $CourseList[]=$row['c_id'];
559
+    $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'");
560
+    $CourseList = array();
561
+    while ($row = Database::fetch_array($result)) {
562
+        $CourseList[] = $row['c_id'];
563 563
     }
564 564
     foreach ($CourseList as $enreg_course) {
565 565
         foreach ($UserList as $enreg_user) {
@@ -570,21 +570,21 @@  discard block
 block discarded – undo
570 570
               "('$id_session','$enreg_course','$enreg_user')");
571 571
         }
572 572
         $sql = "SELECT COUNT(user_id) as nbUsers ".
573
-               " FROM $tbl_session_rel_course_rel_user " .
573
+               " FROM $tbl_session_rel_course_rel_user ".
574 574
                " WHERE session_id='$id_session' ".
575 575
                " AND c_id='$enreg_course'";
576 576
         $rs = Database::query($sql);
577 577
         list($nbr_users) = Database::fetch_array($rs);
578 578
         Database::query("UPDATE $tbl_session_rel_course  ".
579
-               " SET nbr_users=$nbr_users " .
579
+               " SET nbr_users=$nbr_users ".
580 580
                " WHERE session_id='$id_session' ".
581 581
                " AND c_id='$enreg_course'");
582 582
     }
583 583
     foreach ($UserList as $enreg_user) {
584 584
         $enreg_user = (int) $enreg_user;
585 585
         Database::query("INSERT IGNORE INTO $tbl_session_rel_user ".
586
-               " (session_id, user_id, registered_at) " .
587
-               " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')");
586
+               " (session_id, user_id, registered_at) ".
587
+               " VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')");
588 588
     }
589 589
     // We update the number of users in the session
590 590
     $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ".
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
 function syncro_users() {
600 600
     global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn;
601 601
     echo "Connecting ...";
602
-    $ldap_connect = ldap_connect( $ldap_host, $ldap_port);
602
+    $ldap_connect = ldap_connect($ldap_host, $ldap_port);
603 603
     ldap_set_version($ldap_connect);
604 604
     if ($ldap_connect) {
605 605
         //echo " Connect to LDAP server successful ";
606 606
         //echo "Binding ...";
607 607
         $ldap_bind = false;
608
-        $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind);
608
+        $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind);
609 609
         if ($ldap_bind_res) {
610 610
             //echo " LDAP bind successful... ";
611 611
             //echo " Searching for uid... ";
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
             //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login");
614 614
             //echo "<p> ldapDc = '$LDAPbasedn' </p>";
615 615
             $all_user_query = "uid=*";
616
-            if(!empty($ldap_search_dn)) {
616
+            if (!empty($ldap_search_dn)) {
617 617
                 $sr = ldap_search($ldap_connect, $ldap_search_dn, $all_user_query);
618 618
             } else {
619 619
                 $sr = ldap_search($ldap_connect, $ldap_basedn, $all_user_query);
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
             //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr);
622 622
             //echo " Getting entries ...";
623 623
             $info = ldap_get_entries($ldap_connect, $sr);
624
-            for ($key = 0; $key < $info['count']; $key ++) {
624
+            for ($key = 0; $key < $info['count']; $key++) {
625 625
                 $user_id = ldap_add_user_by_array($info[$key], false);
626 626
                 if ($user_id) {
627 627
                     echo "User #$user_id created ";
Please login to merge, or discard this patch.