@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function __construct(Configuration $configuration, ILDAPWrapper $ldap, Access $access) { |
69 | 69 | parent::__construct($ldap); |
70 | 70 | $this->configuration = $configuration; |
71 | - if(is_null(Wizard::$l)) { |
|
71 | + if (is_null(Wizard::$l)) { |
|
72 | 72 | Wizard::$l = \OC::$server->getL10N('user_ldap'); |
73 | 73 | } |
74 | 74 | $this->access = $access; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function __destruct() { |
79 | - if($this->result->hasChanges()) { |
|
79 | + if ($this->result->hasChanges()) { |
|
80 | 80 | $this->configuration->saveConfiguration(); |
81 | 81 | } |
82 | 82 | } |
@@ -91,18 +91,18 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function countEntries($filter, $type) { |
93 | 93 | $reqs = array('ldapHost', 'ldapPort', 'ldapBase'); |
94 | - if($type === 'users') { |
|
94 | + if ($type === 'users') { |
|
95 | 95 | $reqs[] = 'ldapUserFilter'; |
96 | 96 | } |
97 | - if(!$this->checkRequirements($reqs)) { |
|
97 | + if (!$this->checkRequirements($reqs)) { |
|
98 | 98 | throw new \Exception('Requirements not met', 400); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $attr = array('dn'); // default |
102 | 102 | $limit = 1001; |
103 | - if($type === 'groups') { |
|
104 | - $result = $this->access->countGroups($filter, $attr, $limit); |
|
105 | - } else if($type === 'users') { |
|
103 | + if ($type === 'groups') { |
|
104 | + $result = $this->access->countGroups($filter, $attr, $limit); |
|
105 | + } else if ($type === 'users') { |
|
106 | 106 | $result = $this->access->countUsers($filter, $attr, $limit); |
107 | 107 | } else if ($type === 'objects') { |
108 | 108 | $result = $this->access->countObjects($limit); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function formatCountResult($count) { |
124 | 124 | $formatted = ($count !== false) ? $count : 0; |
125 | - if($formatted > 1000) { |
|
125 | + if ($formatted > 1000) { |
|
126 | 126 | $formatted = '> 1000'; |
127 | 127 | } |
128 | 128 | return $formatted; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public function countGroups() { |
132 | 132 | $filter = $this->configuration->ldapGroupFilter; |
133 | 133 | |
134 | - if(empty($filter)) { |
|
134 | + if (empty($filter)) { |
|
135 | 135 | $output = self::$l->n('%s group found', '%s groups found', 0, array(0)); |
136 | 136 | $this->result->addChange('ldap_group_count', $output); |
137 | 137 | return $this->result; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $groupsTotal = $this->formatCountResult($this->countEntries($filter, 'groups')); |
142 | 142 | } catch (\Exception $e) { |
143 | 143 | //400 can be ignored, 500 is forwarded |
144 | - if($e->getCode() === 500) { |
|
144 | + if ($e->getCode() === 500) { |
|
145 | 145 | throw $e; |
146 | 146 | } |
147 | 147 | return false; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function countInBaseDN() { |
174 | 174 | // we don't need to provide a filter in this case |
175 | 175 | $total = $this->countEntries(null, 'objects'); |
176 | - if($total === false) { |
|
176 | + if ($total === false) { |
|
177 | 177 | throw new \Exception('invalid results received'); |
178 | 178 | } |
179 | 179 | $this->result->addChange('ldap_test_base', $total); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return int|bool |
188 | 188 | */ |
189 | 189 | public function countUsersWithAttribute($attr, $existsCheck = false) { |
190 | - if(!$this->checkRequirements(array('ldapHost', |
|
190 | + if (!$this->checkRequirements(array('ldapHost', |
|
191 | 191 | 'ldapPort', |
192 | 192 | 'ldapBase', |
193 | 193 | 'ldapUserFilter', |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | $filter = $this->access->combineFilterWithAnd(array( |
199 | 199 | $this->configuration->ldapUserFilter, |
200 | - $attr . '=*' |
|
200 | + $attr.'=*' |
|
201 | 201 | )); |
202 | 202 | |
203 | 203 | $limit = ($existsCheck === false) ? null : 1; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @throws \Exception |
213 | 213 | */ |
214 | 214 | public function detectUserDisplayNameAttribute() { |
215 | - if(!$this->checkRequirements(array('ldapHost', |
|
215 | + if (!$this->checkRequirements(array('ldapHost', |
|
216 | 216 | 'ldapPort', |
217 | 217 | 'ldapBase', |
218 | 218 | 'ldapUserFilter', |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | // most likely not the default value with upper case N, |
226 | 226 | // verify it still produces a result |
227 | 227 | $count = intval($this->countUsersWithAttribute($attr, true)); |
228 | - if($count > 0) { |
|
228 | + if ($count > 0) { |
|
229 | 229 | //no change, but we sent it back to make sure the user interface |
230 | 230 | //is still correct, even if the ajax call was cancelled meanwhile |
231 | 231 | $this->result->addChange('ldap_display_name', $attr); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | foreach ($displayNameAttrs as $attr) { |
239 | 239 | $count = intval($this->countUsersWithAttribute($attr, true)); |
240 | 240 | |
241 | - if($count > 0) { |
|
241 | + if ($count > 0) { |
|
242 | 242 | $this->applyFind('ldap_display_name', $attr); |
243 | 243 | return $this->result; |
244 | 244 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return WizardResult|bool |
255 | 255 | */ |
256 | 256 | public function detectEmailAttribute() { |
257 | - if(!$this->checkRequirements(array('ldapHost', |
|
257 | + if (!$this->checkRequirements(array('ldapHost', |
|
258 | 258 | 'ldapPort', |
259 | 259 | 'ldapBase', |
260 | 260 | 'ldapUserFilter', |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $attr = $this->configuration->ldapEmailAttribute; |
266 | 266 | if ($attr !== '') { |
267 | 267 | $count = intval($this->countUsersWithAttribute($attr, true)); |
268 | - if($count > 0) { |
|
268 | + if ($count > 0) { |
|
269 | 269 | return false; |
270 | 270 | } |
271 | 271 | $writeLog = true; |
@@ -276,19 +276,19 @@ discard block |
||
276 | 276 | $emailAttributes = array('mail', 'mailPrimaryAddress'); |
277 | 277 | $winner = ''; |
278 | 278 | $maxUsers = 0; |
279 | - foreach($emailAttributes as $attr) { |
|
279 | + foreach ($emailAttributes as $attr) { |
|
280 | 280 | $count = $this->countUsersWithAttribute($attr); |
281 | - if($count > $maxUsers) { |
|
281 | + if ($count > $maxUsers) { |
|
282 | 282 | $maxUsers = $count; |
283 | 283 | $winner = $attr; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if($winner !== '') { |
|
287 | + if ($winner !== '') { |
|
288 | 288 | $this->applyFind('ldap_email_attr', $winner); |
289 | - if($writeLog) { |
|
290 | - \OCP\Util::writeLog('user_ldap', 'The mail attribute has ' . |
|
291 | - 'automatically been reset, because the original value ' . |
|
289 | + if ($writeLog) { |
|
290 | + \OCP\Util::writeLog('user_ldap', 'The mail attribute has '. |
|
291 | + 'automatically been reset, because the original value '. |
|
292 | 292 | 'did not return any results.', \OCP\Util::INFO); |
293 | 293 | } |
294 | 294 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @throws \Exception |
302 | 302 | */ |
303 | 303 | public function determineAttributes() { |
304 | - if(!$this->checkRequirements(array('ldapHost', |
|
304 | + if (!$this->checkRequirements(array('ldapHost', |
|
305 | 305 | 'ldapPort', |
306 | 306 | 'ldapBase', |
307 | 307 | 'ldapUserFilter', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $this->result->addOptions('ldap_loginfilter_attributes', $attributes); |
318 | 318 | |
319 | 319 | $selected = $this->configuration->ldapLoginFilterAttributes; |
320 | - if(is_array($selected) && !empty($selected)) { |
|
320 | + if (is_array($selected) && !empty($selected)) { |
|
321 | 321 | $this->result->addChange('ldap_loginfilter_attributes', $selected); |
322 | 322 | } |
323 | 323 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @throws \Exception |
331 | 331 | */ |
332 | 332 | private function getUserAttributes() { |
333 | - if(!$this->checkRequirements(array('ldapHost', |
|
333 | + if (!$this->checkRequirements(array('ldapHost', |
|
334 | 334 | 'ldapPort', |
335 | 335 | 'ldapBase', |
336 | 336 | 'ldapUserFilter', |
@@ -338,20 +338,20 @@ discard block |
||
338 | 338 | return false; |
339 | 339 | } |
340 | 340 | $cr = $this->getConnection(); |
341 | - if(!$cr) { |
|
341 | + if (!$cr) { |
|
342 | 342 | throw new \Exception('Could not connect to LDAP'); |
343 | 343 | } |
344 | 344 | |
345 | 345 | $base = $this->configuration->ldapBase[0]; |
346 | 346 | $filter = $this->configuration->ldapUserFilter; |
347 | 347 | $rr = $this->ldap->search($cr, $base, $filter, array(), 1, 1); |
348 | - if(!$this->ldap->isResource($rr)) { |
|
348 | + if (!$this->ldap->isResource($rr)) { |
|
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | $er = $this->ldap->firstEntry($cr, $rr); |
352 | 352 | $attributes = $this->ldap->getAttributes($cr, $er); |
353 | 353 | $pureAttributes = array(); |
354 | - for($i = 0; $i < $attributes['count']; $i++) { |
|
354 | + for ($i = 0; $i < $attributes['count']; $i++) { |
|
355 | 355 | $pureAttributes[] = $attributes[$i]; |
356 | 356 | } |
357 | 357 | |
@@ -386,23 +386,23 @@ discard block |
||
386 | 386 | * @throws \Exception |
387 | 387 | */ |
388 | 388 | private function determineGroups($dbKey, $confKey, $testMemberOf = true) { |
389 | - if(!$this->checkRequirements(array('ldapHost', |
|
389 | + if (!$this->checkRequirements(array('ldapHost', |
|
390 | 390 | 'ldapPort', |
391 | 391 | 'ldapBase', |
392 | 392 | ))) { |
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | $cr = $this->getConnection(); |
396 | - if(!$cr) { |
|
396 | + if (!$cr) { |
|
397 | 397 | throw new \Exception('Could not connect to LDAP'); |
398 | 398 | } |
399 | 399 | |
400 | 400 | $this->fetchGroups($dbKey, $confKey); |
401 | 401 | |
402 | - if($testMemberOf) { |
|
402 | + if ($testMemberOf) { |
|
403 | 403 | $this->configuration->hasMemberOfFilterSupport = $this->testMemberOf(); |
404 | 404 | $this->result->markChange(); |
405 | - if(!$this->configuration->hasMemberOfFilterSupport) { |
|
405 | + if (!$this->configuration->hasMemberOfFilterSupport) { |
|
406 | 406 | throw new \Exception('memberOf is not supported by the server'); |
407 | 407 | } |
408 | 408 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames'); |
423 | 423 | |
424 | 424 | $filterParts = array(); |
425 | - foreach($obclasses as $obclass) { |
|
425 | + foreach ($obclasses as $obclass) { |
|
426 | 426 | $filterParts[] = 'objectclass='.$obclass; |
427 | 427 | } |
428 | 428 | //we filter for everything |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | // we need to request dn additionally here, otherwise memberOf |
440 | 440 | // detection will fail later |
441 | 441 | $result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset); |
442 | - foreach($result as $item) { |
|
443 | - if(!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
442 | + foreach ($result as $item) { |
|
443 | + if (!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
444 | 444 | // just in case - no issue known |
445 | 445 | continue; |
446 | 446 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $offset += $limit; |
451 | 451 | } while ($this->access->hasMoreResults()); |
452 | 452 | |
453 | - if(count($groupNames) > 0) { |
|
453 | + if (count($groupNames) > 0) { |
|
454 | 454 | natsort($groupNames); |
455 | 455 | $this->result->addOptions($dbKey, array_values($groupNames)); |
456 | 456 | } else { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | $setFeatures = $this->configuration->$confKey; |
461 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
461 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
462 | 462 | //something is already configured? pre-select it. |
463 | 463 | $this->result->addChange($dbKey, $setFeatures); |
464 | 464 | } |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | } |
467 | 467 | |
468 | 468 | public function determineGroupMemberAssoc() { |
469 | - if(!$this->checkRequirements(array('ldapHost', |
|
469 | + if (!$this->checkRequirements(array('ldapHost', |
|
470 | 470 | 'ldapPort', |
471 | 471 | 'ldapGroupFilter', |
472 | 472 | ))) { |
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | $attribute = $this->detectGroupMemberAssoc(); |
476 | - if($attribute === false) { |
|
476 | + if ($attribute === false) { |
|
477 | 477 | return false; |
478 | 478 | } |
479 | 479 | $this->configuration->setConfiguration(array('ldapGroupMemberAssocAttr' => $attribute)); |
@@ -488,14 +488,14 @@ discard block |
||
488 | 488 | * @throws \Exception |
489 | 489 | */ |
490 | 490 | public function determineGroupObjectClasses() { |
491 | - if(!$this->checkRequirements(array('ldapHost', |
|
491 | + if (!$this->checkRequirements(array('ldapHost', |
|
492 | 492 | 'ldapPort', |
493 | 493 | 'ldapBase', |
494 | 494 | ))) { |
495 | 495 | return false; |
496 | 496 | } |
497 | 497 | $cr = $this->getConnection(); |
498 | - if(!$cr) { |
|
498 | + if (!$cr) { |
|
499 | 499 | throw new \Exception('Could not connect to LDAP'); |
500 | 500 | } |
501 | 501 | |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | * @throws \Exception |
516 | 516 | */ |
517 | 517 | public function determineUserObjectClasses() { |
518 | - if(!$this->checkRequirements(array('ldapHost', |
|
518 | + if (!$this->checkRequirements(array('ldapHost', |
|
519 | 519 | 'ldapPort', |
520 | 520 | 'ldapBase', |
521 | 521 | ))) { |
522 | 522 | return false; |
523 | 523 | } |
524 | 524 | $cr = $this->getConnection(); |
525 | - if(!$cr) { |
|
525 | + if (!$cr) { |
|
526 | 526 | throw new \Exception('Could not connect to LDAP'); |
527 | 527 | } |
528 | 528 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \Exception |
546 | 546 | */ |
547 | 547 | public function getGroupFilter() { |
548 | - if(!$this->checkRequirements(array('ldapHost', |
|
548 | + if (!$this->checkRequirements(array('ldapHost', |
|
549 | 549 | 'ldapPort', |
550 | 550 | 'ldapBase', |
551 | 551 | ))) { |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @throws \Exception |
570 | 570 | */ |
571 | 571 | public function getUserListFilter() { |
572 | - if(!$this->checkRequirements(array('ldapHost', |
|
572 | + if (!$this->checkRequirements(array('ldapHost', |
|
573 | 573 | 'ldapPort', |
574 | 574 | 'ldapBase', |
575 | 575 | ))) { |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $this->applyFind('ldap_display_name', $d['ldap_display_name']); |
583 | 583 | } |
584 | 584 | $filter = $this->composeLdapFilter(self::LFILTER_USER_LIST); |
585 | - if(!$filter) { |
|
585 | + if (!$filter) { |
|
586 | 586 | throw new \Exception('Cannot create filter'); |
587 | 587 | } |
588 | 588 | |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * @throws \Exception |
596 | 596 | */ |
597 | 597 | public function getUserLoginFilter() { |
598 | - if(!$this->checkRequirements(array('ldapHost', |
|
598 | + if (!$this->checkRequirements(array('ldapHost', |
|
599 | 599 | 'ldapPort', |
600 | 600 | 'ldapBase', |
601 | 601 | 'ldapUserFilter', |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | } |
605 | 605 | |
606 | 606 | $filter = $this->composeLdapFilter(self::LFILTER_LOGIN); |
607 | - if(!$filter) { |
|
607 | + if (!$filter) { |
|
608 | 608 | throw new \Exception('Cannot create filter'); |
609 | 609 | } |
610 | 610 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * @throws \Exception |
619 | 619 | */ |
620 | 620 | public function testLoginName($loginName) { |
621 | - if(!$this->checkRequirements(array('ldapHost', |
|
621 | + if (!$this->checkRequirements(array('ldapHost', |
|
622 | 622 | 'ldapPort', |
623 | 623 | 'ldapBase', |
624 | 624 | 'ldapLoginFilter', |
@@ -627,17 +627,17 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | $cr = $this->access->connection->getConnectionResource(); |
630 | - if(!$this->ldap->isResource($cr)) { |
|
630 | + if (!$this->ldap->isResource($cr)) { |
|
631 | 631 | throw new \Exception('connection error'); |
632 | 632 | } |
633 | 633 | |
634 | - if(mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
634 | + if (mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
635 | 635 | === false) { |
636 | 636 | throw new \Exception('missing placeholder'); |
637 | 637 | } |
638 | 638 | |
639 | 639 | $users = $this->access->countUsersByLoginName($loginName); |
640 | - if($this->ldap->errno($cr) !== 0) { |
|
640 | + if ($this->ldap->errno($cr) !== 0) { |
|
641 | 641 | throw new \Exception($this->ldap->error($cr)); |
642 | 642 | } |
643 | 643 | $filter = str_replace('%uid', $loginName, $this->access->connection->ldapLoginFilter); |
@@ -652,22 +652,22 @@ discard block |
||
652 | 652 | * @throws \Exception |
653 | 653 | */ |
654 | 654 | public function guessPortAndTLS() { |
655 | - if(!$this->checkRequirements(array('ldapHost', |
|
655 | + if (!$this->checkRequirements(array('ldapHost', |
|
656 | 656 | ))) { |
657 | 657 | return false; |
658 | 658 | } |
659 | 659 | $this->checkHost(); |
660 | 660 | $portSettings = $this->getPortSettingsToTry(); |
661 | 661 | |
662 | - if(!is_array($portSettings)) { |
|
662 | + if (!is_array($portSettings)) { |
|
663 | 663 | throw new \Exception(print_r($portSettings, true)); |
664 | 664 | } |
665 | 665 | |
666 | 666 | //proceed from the best configuration and return on first success |
667 | - foreach($portSettings as $setting) { |
|
667 | + foreach ($portSettings as $setting) { |
|
668 | 668 | $p = $setting['port']; |
669 | 669 | $t = $setting['tls']; |
670 | - \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG); |
|
670 | + \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '.$p.', TLS '.$t, \OCP\Util::DEBUG); |
|
671 | 671 | //connectAndBind may throw Exception, it needs to be catched by the |
672 | 672 | //callee of this method |
673 | 673 | |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | // any reply other than -1 (= cannot connect) is already okay, |
678 | 678 | // because then we found the server |
679 | 679 | // unavailable startTLS returns -11 |
680 | - if($e->getCode() > 0) { |
|
680 | + if ($e->getCode() > 0) { |
|
681 | 681 | $settingsFound = true; |
682 | 682 | } else { |
683 | 683 | throw $e; |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | 'ldapTLS' => intval($t) |
691 | 691 | ); |
692 | 692 | $this->configuration->setConfiguration($config); |
693 | - \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG); |
|
693 | + \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port '.$p, \OCP\Util::DEBUG); |
|
694 | 694 | $this->result->addChange('ldap_port', $p); |
695 | 695 | return $this->result; |
696 | 696 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * @return WizardResult|false WizardResult on success, false otherwise |
706 | 706 | */ |
707 | 707 | public function guessBaseDN() { |
708 | - if(!$this->checkRequirements(array('ldapHost', |
|
708 | + if (!$this->checkRequirements(array('ldapHost', |
|
709 | 709 | 'ldapPort', |
710 | 710 | ))) { |
711 | 711 | return false; |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | //check whether a DN is given in the agent name (99.9% of all cases) |
715 | 715 | $base = null; |
716 | 716 | $i = stripos($this->configuration->ldapAgentName, 'dc='); |
717 | - if($i !== false) { |
|
717 | + if ($i !== false) { |
|
718 | 718 | $base = substr($this->configuration->ldapAgentName, $i); |
719 | - if($this->testBaseDN($base)) { |
|
719 | + if ($this->testBaseDN($base)) { |
|
720 | 720 | $this->applyFind('ldap_base', $base); |
721 | 721 | return $this->result; |
722 | 722 | } |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | //a base DN |
728 | 728 | $helper = new Helper(\OC::$server->getConfig()); |
729 | 729 | $domain = $helper->getDomainFromURL($this->configuration->ldapHost); |
730 | - if(!$domain) { |
|
730 | + if (!$domain) { |
|
731 | 731 | return false; |
732 | 732 | } |
733 | 733 | |
734 | 734 | $dparts = explode('.', $domain); |
735 | - while(count($dparts) > 0) { |
|
736 | - $base2 = 'dc=' . implode(',dc=', $dparts); |
|
735 | + while (count($dparts) > 0) { |
|
736 | + $base2 = 'dc='.implode(',dc=', $dparts); |
|
737 | 737 | if ($base !== $base2 && $this->testBaseDN($base2)) { |
738 | 738 | $this->applyFind('ldap_base', $base2); |
739 | 739 | return $this->result; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | $hostInfo = parse_url($host); |
767 | 767 | |
768 | 768 | //removes Port from Host |
769 | - if(is_array($hostInfo) && isset($hostInfo['port'])) { |
|
769 | + if (is_array($hostInfo) && isset($hostInfo['port'])) { |
|
770 | 770 | $port = $hostInfo['port']; |
771 | 771 | $host = str_replace(':'.$port, '', $host); |
772 | 772 | $this->applyFind('ldap_host', $host); |
@@ -783,30 +783,30 @@ discard block |
||
783 | 783 | private function detectGroupMemberAssoc() { |
784 | 784 | $possibleAttrs = array('uniqueMember', 'memberUid', 'member', 'gidNumber'); |
785 | 785 | $filter = $this->configuration->ldapGroupFilter; |
786 | - if(empty($filter)) { |
|
786 | + if (empty($filter)) { |
|
787 | 787 | return false; |
788 | 788 | } |
789 | 789 | $cr = $this->getConnection(); |
790 | - if(!$cr) { |
|
790 | + if (!$cr) { |
|
791 | 791 | throw new \Exception('Could not connect to LDAP'); |
792 | 792 | } |
793 | 793 | $base = $this->configuration->ldapBase[0]; |
794 | 794 | $rr = $this->ldap->search($cr, $base, $filter, $possibleAttrs, 0, 1000); |
795 | - if(!$this->ldap->isResource($rr)) { |
|
795 | + if (!$this->ldap->isResource($rr)) { |
|
796 | 796 | return false; |
797 | 797 | } |
798 | 798 | $er = $this->ldap->firstEntry($cr, $rr); |
799 | - while(is_resource($er)) { |
|
799 | + while (is_resource($er)) { |
|
800 | 800 | $this->ldap->getDN($cr, $er); |
801 | 801 | $attrs = $this->ldap->getAttributes($cr, $er); |
802 | 802 | $result = array(); |
803 | 803 | $possibleAttrsCount = count($possibleAttrs); |
804 | - for($i = 0; $i < $possibleAttrsCount; $i++) { |
|
805 | - if(isset($attrs[$possibleAttrs[$i]])) { |
|
804 | + for ($i = 0; $i < $possibleAttrsCount; $i++) { |
|
805 | + if (isset($attrs[$possibleAttrs[$i]])) { |
|
806 | 806 | $result[$possibleAttrs[$i]] = $attrs[$possibleAttrs[$i]]['count']; |
807 | 807 | } |
808 | 808 | } |
809 | - if(!empty($result)) { |
|
809 | + if (!empty($result)) { |
|
810 | 810 | natsort($result); |
811 | 811 | return key($result); |
812 | 812 | } |
@@ -825,14 +825,14 @@ discard block |
||
825 | 825 | */ |
826 | 826 | private function testBaseDN($base) { |
827 | 827 | $cr = $this->getConnection(); |
828 | - if(!$cr) { |
|
828 | + if (!$cr) { |
|
829 | 829 | throw new \Exception('Could not connect to LDAP'); |
830 | 830 | } |
831 | 831 | |
832 | 832 | //base is there, let's validate it. If we search for anything, we should |
833 | 833 | //get a result set > 0 on a proper base |
834 | 834 | $rr = $this->ldap->search($cr, $base, 'objectClass=*', array('dn'), 0, 1); |
835 | - if(!$this->ldap->isResource($rr)) { |
|
835 | + if (!$this->ldap->isResource($rr)) { |
|
836 | 836 | $errorNo = $this->ldap->errno($cr); |
837 | 837 | $errorMsg = $this->ldap->error($cr); |
838 | 838 | \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. |
@@ -854,11 +854,11 @@ discard block |
||
854 | 854 | */ |
855 | 855 | private function testMemberOf() { |
856 | 856 | $cr = $this->getConnection(); |
857 | - if(!$cr) { |
|
857 | + if (!$cr) { |
|
858 | 858 | throw new \Exception('Could not connect to LDAP'); |
859 | 859 | } |
860 | 860 | $result = $this->access->countUsers('memberOf=*', array('memberOf'), 1); |
861 | - if(is_int($result) && $result > 0) { |
|
861 | + if (is_int($result) && $result > 0) { |
|
862 | 862 | return true; |
863 | 863 | } |
864 | 864 | return false; |
@@ -879,27 +879,27 @@ discard block |
||
879 | 879 | case self::LFILTER_USER_LIST: |
880 | 880 | $objcs = $this->configuration->ldapUserFilterObjectclass; |
881 | 881 | //glue objectclasses |
882 | - if(is_array($objcs) && count($objcs) > 0) { |
|
882 | + if (is_array($objcs) && count($objcs) > 0) { |
|
883 | 883 | $filter .= '(|'; |
884 | - foreach($objcs as $objc) { |
|
885 | - $filter .= '(objectclass=' . $objc . ')'; |
|
884 | + foreach ($objcs as $objc) { |
|
885 | + $filter .= '(objectclass='.$objc.')'; |
|
886 | 886 | } |
887 | 887 | $filter .= ')'; |
888 | 888 | $parts++; |
889 | 889 | } |
890 | 890 | //glue group memberships |
891 | - if($this->configuration->hasMemberOfFilterSupport) { |
|
891 | + if ($this->configuration->hasMemberOfFilterSupport) { |
|
892 | 892 | $cns = $this->configuration->ldapUserFilterGroups; |
893 | - if(is_array($cns) && count($cns) > 0) { |
|
893 | + if (is_array($cns) && count($cns) > 0) { |
|
894 | 894 | $filter .= '(|'; |
895 | 895 | $cr = $this->getConnection(); |
896 | - if(!$cr) { |
|
896 | + if (!$cr) { |
|
897 | 897 | throw new \Exception('Could not connect to LDAP'); |
898 | 898 | } |
899 | 899 | $base = $this->configuration->ldapBase[0]; |
900 | - foreach($cns as $cn) { |
|
901 | - $rr = $this->ldap->search($cr, $base, 'cn=' . $cn, array('dn', 'primaryGroupToken')); |
|
902 | - if(!$this->ldap->isResource($rr)) { |
|
900 | + foreach ($cns as $cn) { |
|
901 | + $rr = $this->ldap->search($cr, $base, 'cn='.$cn, array('dn', 'primaryGroupToken')); |
|
902 | + if (!$this->ldap->isResource($rr)) { |
|
903 | 903 | continue; |
904 | 904 | } |
905 | 905 | $er = $this->ldap->firstEntry($cr, $rr); |
@@ -908,11 +908,11 @@ discard block |
||
908 | 908 | if ($dn == false || $dn === '') { |
909 | 909 | continue; |
910 | 910 | } |
911 | - $filterPart = '(memberof=' . $dn . ')'; |
|
912 | - if(isset($attrs['primaryGroupToken'])) { |
|
911 | + $filterPart = '(memberof='.$dn.')'; |
|
912 | + if (isset($attrs['primaryGroupToken'])) { |
|
913 | 913 | $pgt = $attrs['primaryGroupToken'][0]; |
914 | - $primaryFilterPart = '(primaryGroupID=' . $pgt .')'; |
|
915 | - $filterPart = '(|' . $filterPart . $primaryFilterPart . ')'; |
|
914 | + $primaryFilterPart = '(primaryGroupID='.$pgt.')'; |
|
915 | + $filterPart = '(|'.$filterPart.$primaryFilterPart.')'; |
|
916 | 916 | } |
917 | 917 | $filter .= $filterPart; |
918 | 918 | } |
@@ -921,8 +921,8 @@ discard block |
||
921 | 921 | $parts++; |
922 | 922 | } |
923 | 923 | //wrap parts in AND condition |
924 | - if($parts > 1) { |
|
925 | - $filter = '(&' . $filter . ')'; |
|
924 | + if ($parts > 1) { |
|
925 | + $filter = '(&'.$filter.')'; |
|
926 | 926 | } |
927 | 927 | if ($filter === '') { |
928 | 928 | $filter = '(objectclass=*)'; |
@@ -932,27 +932,27 @@ discard block |
||
932 | 932 | case self::LFILTER_GROUP_LIST: |
933 | 933 | $objcs = $this->configuration->ldapGroupFilterObjectclass; |
934 | 934 | //glue objectclasses |
935 | - if(is_array($objcs) && count($objcs) > 0) { |
|
935 | + if (is_array($objcs) && count($objcs) > 0) { |
|
936 | 936 | $filter .= '(|'; |
937 | - foreach($objcs as $objc) { |
|
938 | - $filter .= '(objectclass=' . $objc . ')'; |
|
937 | + foreach ($objcs as $objc) { |
|
938 | + $filter .= '(objectclass='.$objc.')'; |
|
939 | 939 | } |
940 | 940 | $filter .= ')'; |
941 | 941 | $parts++; |
942 | 942 | } |
943 | 943 | //glue group memberships |
944 | 944 | $cns = $this->configuration->ldapGroupFilterGroups; |
945 | - if(is_array($cns) && count($cns) > 0) { |
|
945 | + if (is_array($cns) && count($cns) > 0) { |
|
946 | 946 | $filter .= '(|'; |
947 | - foreach($cns as $cn) { |
|
948 | - $filter .= '(cn=' . $cn . ')'; |
|
947 | + foreach ($cns as $cn) { |
|
948 | + $filter .= '(cn='.$cn.')'; |
|
949 | 949 | } |
950 | 950 | $filter .= ')'; |
951 | 951 | } |
952 | 952 | $parts++; |
953 | 953 | //wrap parts in AND condition |
954 | - if($parts > 1) { |
|
955 | - $filter = '(&' . $filter . ')'; |
|
954 | + if ($parts > 1) { |
|
955 | + $filter = '(&'.$filter.')'; |
|
956 | 956 | } |
957 | 957 | break; |
958 | 958 | |
@@ -964,47 +964,47 @@ discard block |
||
964 | 964 | $userAttributes = array_change_key_case(array_flip($userAttributes)); |
965 | 965 | $parts = 0; |
966 | 966 | |
967 | - if($this->configuration->ldapLoginFilterUsername === '1') { |
|
967 | + if ($this->configuration->ldapLoginFilterUsername === '1') { |
|
968 | 968 | $attr = ''; |
969 | - if(isset($userAttributes['uid'])) { |
|
969 | + if (isset($userAttributes['uid'])) { |
|
970 | 970 | $attr = 'uid'; |
971 | - } else if(isset($userAttributes['samaccountname'])) { |
|
971 | + } else if (isset($userAttributes['samaccountname'])) { |
|
972 | 972 | $attr = 'samaccountname'; |
973 | - } else if(isset($userAttributes['cn'])) { |
|
973 | + } else if (isset($userAttributes['cn'])) { |
|
974 | 974 | //fallback |
975 | 975 | $attr = 'cn'; |
976 | 976 | } |
977 | 977 | if ($attr !== '') { |
978 | - $filterUsername = '(' . $attr . $loginpart . ')'; |
|
978 | + $filterUsername = '('.$attr.$loginpart.')'; |
|
979 | 979 | $parts++; |
980 | 980 | } |
981 | 981 | } |
982 | 982 | |
983 | 983 | $filterEmail = ''; |
984 | - if($this->configuration->ldapLoginFilterEmail === '1') { |
|
984 | + if ($this->configuration->ldapLoginFilterEmail === '1') { |
|
985 | 985 | $filterEmail = '(|(mailPrimaryAddress=%uid)(mail=%uid))'; |
986 | 986 | $parts++; |
987 | 987 | } |
988 | 988 | |
989 | 989 | $filterAttributes = ''; |
990 | 990 | $attrsToFilter = $this->configuration->ldapLoginFilterAttributes; |
991 | - if(is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
991 | + if (is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
992 | 992 | $filterAttributes = '(|'; |
993 | - foreach($attrsToFilter as $attribute) { |
|
994 | - $filterAttributes .= '(' . $attribute . $loginpart . ')'; |
|
993 | + foreach ($attrsToFilter as $attribute) { |
|
994 | + $filterAttributes .= '('.$attribute.$loginpart.')'; |
|
995 | 995 | } |
996 | 996 | $filterAttributes .= ')'; |
997 | 997 | $parts++; |
998 | 998 | } |
999 | 999 | |
1000 | 1000 | $filterLogin = ''; |
1001 | - if($parts > 1) { |
|
1001 | + if ($parts > 1) { |
|
1002 | 1002 | $filterLogin = '(|'; |
1003 | 1003 | } |
1004 | 1004 | $filterLogin .= $filterUsername; |
1005 | 1005 | $filterLogin .= $filterEmail; |
1006 | 1006 | $filterLogin .= $filterAttributes; |
1007 | - if($parts > 1) { |
|
1007 | + if ($parts > 1) { |
|
1008 | 1008 | $filterLogin .= ')'; |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | * @throws \Exception |
1027 | 1027 | */ |
1028 | 1028 | private function connectAndBind($port = 389, $tls = false, $ncc = false) { |
1029 | - if($ncc) { |
|
1029 | + if ($ncc) { |
|
1030 | 1030 | $originalLDAPTLS_REQCERT = strval(getenv('LDAPTLS_REQCERT')); |
1031 | 1031 | //No certificate check |
1032 | 1032 | putenv('LDAPTLS_REQCERT=never'); |
@@ -1036,12 +1036,12 @@ discard block |
||
1036 | 1036 | \OCP\Util::writeLog('user_ldap', 'Wiz: Checking Host Info ', \OCP\Util::DEBUG); |
1037 | 1037 | $host = $this->configuration->ldapHost; |
1038 | 1038 | $hostInfo = parse_url($host); |
1039 | - if(!$hostInfo) { |
|
1039 | + if (!$hostInfo) { |
|
1040 | 1040 | throw new \Exception(self::$l->t('Invalid Host')); |
1041 | 1041 | } |
1042 | 1042 | \OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', \OCP\Util::DEBUG); |
1043 | 1043 | $cr = $this->ldap->connect($host, $port); |
1044 | - if(!is_resource($cr)) { |
|
1044 | + if (!is_resource($cr)) { |
|
1045 | 1045 | throw new \Exception(self::$l->t('Invalid Host')); |
1046 | 1046 | } |
1047 | 1047 | |
@@ -1052,9 +1052,9 @@ discard block |
||
1052 | 1052 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1053 | 1053 | |
1054 | 1054 | try { |
1055 | - if($tls) { |
|
1055 | + if ($tls) { |
|
1056 | 1056 | $isTlsWorking = @$this->ldap->startTls($cr); |
1057 | - if(!$isTlsWorking) { |
|
1057 | + if (!$isTlsWorking) { |
|
1058 | 1058 | return false; |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1068,27 +1068,27 @@ discard block |
||
1068 | 1068 | $errNo = $this->ldap->errno($cr); |
1069 | 1069 | $error = ldap_error($cr); |
1070 | 1070 | $this->ldap->unbind($cr); |
1071 | - } catch(ServerNotAvailableException $e) { |
|
1072 | - if($ncc && isset($originalLDAPTLS_REQCERT)) { |
|
1073 | - putenv('LDAPTLS_REQCERT=' . $originalLDAPTLS_REQCERT); |
|
1071 | + } catch (ServerNotAvailableException $e) { |
|
1072 | + if ($ncc && isset($originalLDAPTLS_REQCERT)) { |
|
1073 | + putenv('LDAPTLS_REQCERT='.$originalLDAPTLS_REQCERT); |
|
1074 | 1074 | } |
1075 | 1075 | return false; |
1076 | 1076 | } |
1077 | 1077 | |
1078 | - if($ncc && isset($originalLDAPTLS_REQCERT)) { |
|
1079 | - putenv('LDAPTLS_REQCERT=' . $originalLDAPTLS_REQCERT); |
|
1078 | + if ($ncc && isset($originalLDAPTLS_REQCERT)) { |
|
1079 | + putenv('LDAPTLS_REQCERT='.$originalLDAPTLS_REQCERT); |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | - if($login === true) { |
|
1082 | + if ($login === true) { |
|
1083 | 1083 | $this->ldap->unbind($cr); |
1084 | - if($ncc) { |
|
1084 | + if ($ncc) { |
|
1085 | 1085 | throw new \Exception('Certificate cannot be validated.'); |
1086 | 1086 | } |
1087 | - \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . intval($tls), \OCP\Util::DEBUG); |
|
1087 | + \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '.$port.' TLS '.intval($tls), \OCP\Util::DEBUG); |
|
1088 | 1088 | return true; |
1089 | 1089 | } |
1090 | 1090 | |
1091 | - if($errNo === -1 || ($errNo === 2 && $ncc)) { |
|
1091 | + if ($errNo === -1 || ($errNo === 2 && $ncc)) { |
|
1092 | 1092 | //host, port or TLS wrong |
1093 | 1093 | return false; |
1094 | 1094 | } else if ($errNo === 2) { |
@@ -1118,9 +1118,9 @@ discard block |
||
1118 | 1118 | */ |
1119 | 1119 | private function checkRequirements($reqs) { |
1120 | 1120 | $this->checkAgentRequirements(); |
1121 | - foreach($reqs as $option) { |
|
1121 | + foreach ($reqs as $option) { |
|
1122 | 1122 | $value = $this->configuration->$option; |
1123 | - if(empty($value)) { |
|
1123 | + if (empty($value)) { |
|
1124 | 1124 | return false; |
1125 | 1125 | } |
1126 | 1126 | } |
@@ -1142,33 +1142,33 @@ discard block |
||
1142 | 1142 | $dnRead = array(); |
1143 | 1143 | $foundItems = array(); |
1144 | 1144 | $maxEntries = 0; |
1145 | - if(!is_array($this->configuration->ldapBase) |
|
1145 | + if (!is_array($this->configuration->ldapBase) |
|
1146 | 1146 | || !isset($this->configuration->ldapBase[0])) { |
1147 | 1147 | return false; |
1148 | 1148 | } |
1149 | 1149 | $base = $this->configuration->ldapBase[0]; |
1150 | 1150 | $cr = $this->getConnection(); |
1151 | - if(!$this->ldap->isResource($cr)) { |
|
1151 | + if (!$this->ldap->isResource($cr)) { |
|
1152 | 1152 | return false; |
1153 | 1153 | } |
1154 | 1154 | $lastFilter = null; |
1155 | - if(isset($filters[count($filters)-1])) { |
|
1156 | - $lastFilter = $filters[count($filters)-1]; |
|
1155 | + if (isset($filters[count($filters) - 1])) { |
|
1156 | + $lastFilter = $filters[count($filters) - 1]; |
|
1157 | 1157 | } |
1158 | - foreach($filters as $filter) { |
|
1159 | - if($lastFilter === $filter && count($foundItems) > 0) { |
|
1158 | + foreach ($filters as $filter) { |
|
1159 | + if ($lastFilter === $filter && count($foundItems) > 0) { |
|
1160 | 1160 | //skip when the filter is a wildcard and results were found |
1161 | 1161 | continue; |
1162 | 1162 | } |
1163 | 1163 | // 20k limit for performance and reason |
1164 | 1164 | $rr = $this->ldap->search($cr, $base, $filter, array($attr), 0, 20000); |
1165 | - if(!$this->ldap->isResource($rr)) { |
|
1165 | + if (!$this->ldap->isResource($rr)) { |
|
1166 | 1166 | continue; |
1167 | 1167 | } |
1168 | 1168 | $entries = $this->ldap->countEntries($cr, $rr); |
1169 | 1169 | $getEntryFunc = 'firstEntry'; |
1170 | - if(($entries !== false) && ($entries > 0)) { |
|
1171 | - if(!is_null($maxF) && $entries > $maxEntries) { |
|
1170 | + if (($entries !== false) && ($entries > 0)) { |
|
1171 | + if (!is_null($maxF) && $entries > $maxEntries) { |
|
1172 | 1172 | $maxEntries = $entries; |
1173 | 1173 | $maxF = $filter; |
1174 | 1174 | } |
@@ -1176,13 +1176,13 @@ discard block |
||
1176 | 1176 | do { |
1177 | 1177 | $entry = $this->ldap->$getEntryFunc($cr, $rr); |
1178 | 1178 | $getEntryFunc = 'nextEntry'; |
1179 | - if(!$this->ldap->isResource($entry)) { |
|
1179 | + if (!$this->ldap->isResource($entry)) { |
|
1180 | 1180 | continue 2; |
1181 | 1181 | } |
1182 | 1182 | $rr = $entry; //will be expected by nextEntry next round |
1183 | 1183 | $attributes = $this->ldap->getAttributes($cr, $entry); |
1184 | 1184 | $dn = $this->ldap->getDN($cr, $entry); |
1185 | - if($dn === false || in_array($dn, $dnRead)) { |
|
1185 | + if ($dn === false || in_array($dn, $dnRead)) { |
|
1186 | 1186 | continue; |
1187 | 1187 | } |
1188 | 1188 | $newItems = array(); |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | $foundItems = array_merge($foundItems, $newItems); |
1194 | 1194 | $this->resultCache[$dn][$attr] = $newItems; |
1195 | 1195 | $dnRead[] = $dn; |
1196 | - } while(($state === self::LRESULT_PROCESSED_SKIP |
|
1196 | + } while (($state === self::LRESULT_PROCESSED_SKIP |
|
1197 | 1197 | || $this->ldap->isResource($entry)) |
1198 | 1198 | && ($dnReadLimit === 0 || $dnReadCount < $dnReadLimit)); |
1199 | 1199 | } |
@@ -1216,11 +1216,11 @@ discard block |
||
1216 | 1216 | */ |
1217 | 1217 | private function determineFeature($objectclasses, $attr, $dbkey, $confkey, $po = false) { |
1218 | 1218 | $cr = $this->getConnection(); |
1219 | - if(!$cr) { |
|
1219 | + if (!$cr) { |
|
1220 | 1220 | throw new \Exception('Could not connect to LDAP'); |
1221 | 1221 | } |
1222 | 1222 | $p = 'objectclass='; |
1223 | - foreach($objectclasses as $key => $value) { |
|
1223 | + foreach ($objectclasses as $key => $value) { |
|
1224 | 1224 | $objectclasses[$key] = $p.$value; |
1225 | 1225 | } |
1226 | 1226 | $maxEntryObjC = ''; |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | $availableFeatures = |
1233 | 1233 | $this->cumulativeSearchOnAttribute($objectclasses, $attr, |
1234 | 1234 | $dig, $maxEntryObjC); |
1235 | - if(is_array($availableFeatures) |
|
1235 | + if (is_array($availableFeatures) |
|
1236 | 1236 | && count($availableFeatures) > 0) { |
1237 | 1237 | natcasesort($availableFeatures); |
1238 | 1238 | //natcasesort keeps indices, but we must get rid of them for proper |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | $setFeatures = $this->configuration->$confkey; |
1246 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
1246 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
1247 | 1247 | //something is already configured? pre-select it. |
1248 | 1248 | $this->result->addChange($dbkey, $setFeatures); |
1249 | 1249 | } else if ($po && $maxEntryObjC !== '') { |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | * LRESULT_PROCESSED_INVALID or LRESULT_PROCESSED_SKIP |
1266 | 1266 | */ |
1267 | 1267 | private function getAttributeValuesFromEntry($result, $attribute, &$known) { |
1268 | - if(!is_array($result) |
|
1268 | + if (!is_array($result) |
|
1269 | 1269 | || !isset($result['count']) |
1270 | 1270 | || !$result['count'] > 0) { |
1271 | 1271 | return self::LRESULT_PROCESSED_INVALID; |
@@ -1274,12 +1274,12 @@ discard block |
||
1274 | 1274 | // strtolower on all keys for proper comparison |
1275 | 1275 | $result = \OCP\Util::mb_array_change_key_case($result); |
1276 | 1276 | $attribute = strtolower($attribute); |
1277 | - if(isset($result[$attribute])) { |
|
1278 | - foreach($result[$attribute] as $key => $val) { |
|
1279 | - if($key === 'count') { |
|
1277 | + if (isset($result[$attribute])) { |
|
1278 | + foreach ($result[$attribute] as $key => $val) { |
|
1279 | + if ($key === 'count') { |
|
1280 | 1280 | continue; |
1281 | 1281 | } |
1282 | - if(!in_array($val, $known)) { |
|
1282 | + if (!in_array($val, $known)) { |
|
1283 | 1283 | $known[] = $val; |
1284 | 1284 | } |
1285 | 1285 | } |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | * @return bool|mixed |
1294 | 1294 | */ |
1295 | 1295 | private function getConnection() { |
1296 | - if(!is_null($this->cr)) { |
|
1296 | + if (!is_null($this->cr)) { |
|
1297 | 1297 | return $this->cr; |
1298 | 1298 | } |
1299 | 1299 | |
@@ -1305,14 +1305,14 @@ discard block |
||
1305 | 1305 | $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); |
1306 | 1306 | $this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0); |
1307 | 1307 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1308 | - if($this->configuration->ldapTLS === 1) { |
|
1308 | + if ($this->configuration->ldapTLS === 1) { |
|
1309 | 1309 | $this->ldap->startTls($cr); |
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | $lo = @$this->ldap->bind($cr, |
1313 | 1313 | $this->configuration->ldapAgentName, |
1314 | 1314 | $this->configuration->ldapAgentPassword); |
1315 | - if($lo === true) { |
|
1315 | + if ($lo === true) { |
|
1316 | 1316 | $this->$cr = $cr; |
1317 | 1317 | return $cr; |
1318 | 1318 | } |
@@ -1347,14 +1347,14 @@ discard block |
||
1347 | 1347 | $portSettings = array(); |
1348 | 1348 | |
1349 | 1349 | //In case the port is already provided, we will check this first |
1350 | - if($port > 0) { |
|
1350 | + if ($port > 0) { |
|
1351 | 1351 | $hostInfo = parse_url($host); |
1352 | - if(!(is_array($hostInfo) |
|
1352 | + if (!(is_array($hostInfo) |
|
1353 | 1353 | && isset($hostInfo['scheme']) |
1354 | 1354 | && stripos($hostInfo['scheme'], 'ldaps') !== false)) { |
1355 | 1355 | $portSettings[] = array('port' => $port, 'tls' => true); |
1356 | 1356 | } |
1357 | - $portSettings[] =array('port' => $port, 'tls' => false); |
|
1357 | + $portSettings[] = array('port' => $port, 'tls' => false); |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | //default ports |