@@ -133,6 +133,10 @@ discard block |
||
133 | 133 | protected $userDN; |
134 | 134 | |
135 | 135 | # Create AD password (Microsoft Active Directory password format) |
136 | + |
|
137 | + /** |
|
138 | + * @param string $password |
|
139 | + */ |
|
136 | 140 | protected static function encodePassword($password) { |
137 | 141 | $password = "\"" . $password . "\""; |
138 | 142 | $adpassword = mb_convert_encoding($password, "UTF-16LE", "UTF-8"); |
@@ -230,7 +234,7 @@ discard block |
||
230 | 234 | * Authenticate user |
231 | 235 | * @param string $username |
232 | 236 | * @param string $password |
233 | - * @return int indicate occurrence of error. |
|
237 | + * @return boolean indicate occurrence of error. |
|
234 | 238 | */ |
235 | 239 | public function auth($username, $password) |
236 | 240 | { |
@@ -563,8 +567,6 @@ discard block |
||
563 | 567 | |
564 | 568 | /** |
565 | 569 | * Send LDAP pagination control. |
566 | - * @param int $pageSize |
|
567 | - * @param bool $isCritical |
|
568 | 570 | * @param string $cookie |
569 | 571 | * @return bool |
570 | 572 | */ |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | # Create AD password (Microsoft Active Directory password format) |
136 | 136 | protected static function encodePassword($password) { |
137 | - $password = "\"" . $password . "\""; |
|
137 | + $password = "\"".$password."\""; |
|
138 | 138 | $adpassword = mb_convert_encoding($password, "UTF-16LE", "UTF-8"); |
139 | 139 | return $adpassword; |
140 | 140 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function open($anonymous = false) |
185 | 185 | { |
186 | - $token = 'Opening LDAP connection: ' . LdapUtils::recursive_implode($this->dc, ' or '); |
|
186 | + $token = 'Opening LDAP connection: '.LdapUtils::recursive_implode($this->dc, ' or '); |
|
187 | 187 | Yii::info($token, __METHOD__); |
188 | 188 | Yii::beginProfile($token, __METHOD__); |
189 | 189 | // Connect to the LDAP server. |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | # Search for user and get user DN |
241 | 241 | $searchResult = ldap_search($this->resource, $this->baseDn, "(&(objectClass=person)($this->loginAttribute=$username))", [$this->loginAttribute]); |
242 | 242 | $entry = $this->getFirstEntry($searchResult); |
243 | - if($entry) { |
|
243 | + if ($entry) { |
|
244 | 244 | $this->userDN = $this->getDn($entry); |
245 | 245 | } else { |
246 | 246 | $this->userDN = null; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | // Open connection with user |
272 | - if(!$this->auth($username, $oldPassword)){ |
|
272 | + if (!$this->auth($username, $oldPassword)) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
@@ -326,20 +326,20 @@ discard block |
||
326 | 326 | $this->open(); |
327 | 327 | $results = []; |
328 | 328 | $cookie = ''; |
329 | - $token = $function . ' - params: ' . LdapUtils::recursive_implode($params, ';'); |
|
329 | + $token = $function.' - params: '.LdapUtils::recursive_implode($params, ';'); |
|
330 | 330 | |
331 | - Yii::info($token , 'chrmorandi\ldap\Connection::query'); |
|
331 | + Yii::info($token, 'chrmorandi\ldap\Connection::query'); |
|
332 | 332 | |
333 | 333 | Yii::beginProfile($token, 'chrmorandi\ldap\Connection::query'); |
334 | 334 | do { |
335 | - if($this->pageSize > 0) { |
|
335 | + if ($this->pageSize > 0) { |
|
336 | 336 | $this->setControlPagedResult($cookie); |
337 | 337 | } |
338 | 338 | |
339 | 339 | // Run the search. |
340 | 340 | $result = call_user_func($function, $this->resource, ...$params); |
341 | 341 | |
342 | - if($this->pageSize > 0) { |
|
342 | + if ($this->pageSize > 0) { |
|
343 | 343 | $this->setControlPagedResultResponse($result, $cookie); |
344 | 344 | } |
345 | 345 |