@@ -134,6 +134,10 @@ |
||
| 134 | 134 | protected $userDN; |
| 135 | 135 | |
| 136 | 136 | # Create AD password (Microsoft Active Directory password format) |
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param string $password |
|
| 140 | + */ |
|
| 137 | 141 | protected static function encodePassword($password) { |
| 138 | 142 | $password = "\"" . $password . "\""; |
| 139 | 143 | $adpassword = mb_convert_encoding($password, "UTF-16LE", "UTF-8"); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | # Create AD password (Microsoft Active Directory password format) |
| 137 | 137 | protected static function encodePassword($password) { |
| 138 | - $password = "\"" . $password . "\""; |
|
| 138 | + $password = "\"".$password."\""; |
|
| 139 | 139 | $adpassword = mb_convert_encoding($password, "UTF-16LE", "UTF-8"); |
| 140 | 140 | return $adpassword; |
| 141 | 141 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function open($anonymous = false) |
| 186 | 186 | { |
| 187 | - $token = 'Opening LDAP connection: ' . LdapUtils::recursive_implode($this->dc, ' or '); |
|
| 187 | + $token = 'Opening LDAP connection: '.LdapUtils::recursive_implode($this->dc, ' or '); |
|
| 188 | 188 | Yii::info($token, __METHOD__); |
| 189 | 189 | Yii::beginProfile($token, __METHOD__); |
| 190 | 190 | // Connect to the LDAP server. |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | # Search for user and get user DN |
| 244 | 244 | $searchResult = ldap_search($this->resource, $this->baseDn, "(&(objectClass=person)($this->loginAttribute=$username))", [$this->loginAttribute]); |
| 245 | 245 | $entry = $this->getFirstEntry($searchResult); |
| 246 | - if($entry) { |
|
| 246 | + if ($entry) { |
|
| 247 | 247 | $this->userDN = $this->getDn($entry); |
| 248 | 248 | } else { |
| 249 | 249 | // User not found. |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // Open connection with user |
| 276 | - if(!$this->auth($username, $oldPassword)){ |
|
| 276 | + if (!$this->auth($username, $oldPassword)) { |
|
| 277 | 277 | return false; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -330,20 +330,20 @@ discard block |
||
| 330 | 330 | $this->open(); |
| 331 | 331 | $results = []; |
| 332 | 332 | $cookie = ''; |
| 333 | - $token = $function . ' - params: ' . LdapUtils::recursive_implode($params, ';'); |
|
| 333 | + $token = $function.' - params: '.LdapUtils::recursive_implode($params, ';'); |
|
| 334 | 334 | |
| 335 | - Yii::info($token , 'chrmorandi\ldap\Connection::query'); |
|
| 335 | + Yii::info($token, 'chrmorandi\ldap\Connection::query'); |
|
| 336 | 336 | |
| 337 | 337 | Yii::beginProfile($token, 'chrmorandi\ldap\Connection::query'); |
| 338 | 338 | do { |
| 339 | - if($this->pageSize > 0) { |
|
| 339 | + if ($this->pageSize > 0) { |
|
| 340 | 340 | $this->setControlPagedResult($cookie); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Run the search. |
| 344 | 344 | $result = call_user_func($function, $this->resource, ...$params); |
| 345 | 345 | |
| 346 | - if($this->pageSize > 0) { |
|
| 346 | + if ($this->pageSize > 0) { |
|
| 347 | 347 | $this->setControlPagedResultResponse($result, $cookie); |
| 348 | 348 | } |
| 349 | 349 | |
@@ -132,7 +132,7 @@ |
||
| 132 | 132 | return '('.$this->operator[$operator].'('.implode(") (", $parts).')'.implode($other).')'; |
| 133 | 133 | } else if (!empty($other)) { |
| 134 | 134 | return '('.$this->operator[$operator].implode($other).')'; |
| 135 | - }else { |
|
| 135 | + } else { |
|
| 136 | 136 | return ''; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -132,7 +132,7 @@ |
||
| 132 | 132 | return '('.$this->operator[$operator].'('.implode(") (", $parts).')'.implode($other).')'; |
| 133 | 133 | } else if (!empty($other)) { |
| 134 | 134 | return '('.$this->operator[$operator].implode($other).')'; |
| 135 | - }else { |
|
| 135 | + } else { |
|
| 136 | 136 | return ''; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $select = (is_array($this->select)) ? $this->select : []; |
| 98 | 98 | |
| 99 | - if(ctype_digit((string) $this->limit)){ |
|
| 99 | + if (ctype_digit((string) $this->limit)) { |
|
| 100 | 100 | $db->pageSize = $this->limit; |
| 101 | 101 | } |
| 102 | - if(ctype_digit((string) $this->offset)){ |
|
| 102 | + if (ctype_digit((string) $this->offset)) { |
|
| 103 | 103 | $db->offset = $this->offset == 0 ? 1 : $this->offset; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function all($db = null) |
| 118 | 118 | { |
| 119 | - if(!($this->dataReader instanceof DataReader)) { |
|
| 119 | + if (!($this->dataReader instanceof DataReader)) { |
|
| 120 | 120 | /** @var $result DataReader */ |
| 121 | 121 | $this->dataReader = $this->execute($db); |
| 122 | 122 | } else { |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | $db = Yii::$app->get('ldap'); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if(ctype_digit((string) $this->limit)){ |
|
| 127 | + if (ctype_digit((string) $this->limit)) { |
|
| 128 | 128 | $db->pageSize = $this->limit; |
| 129 | 129 | } |
| 130 | - if(ctype_digit((string) $this->offset)){ |
|
| 130 | + if (ctype_digit((string) $this->offset)) { |
|
| 131 | 131 | $db->offset = $this->offset == 0 ? 1 : $this->offset; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -26,11 +26,11 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | public $dn; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Returns the list of attribute names. |
|
| 31 | - * By default, this method returns all public properties of the class. |
|
| 32 | - * @return array list of attribute names. |
|
| 33 | - */ |
|
| 29 | + /** |
|
| 30 | + * Returns the list of attribute names. |
|
| 31 | + * By default, this method returns all public properties of the class. |
|
| 32 | + * @return array list of attribute names. |
|
| 33 | + */ |
|
| 34 | 34 | public function getAttributes() { |
| 35 | 35 | $class = new ReflectionClass(self::class); |
| 36 | 36 | $names = []; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | return []; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $token = 'Get entries with limit pagination ' . $this->_conn->pageSize; |
|
| 131 | + $token = 'Get entries with limit pagination '.$this->_conn->pageSize; |
|
| 132 | 132 | Yii::beginProfile($token, __METHOD__); |
| 133 | 133 | if ($this->_conn->offset > 0) { |
| 134 | 134 | $this->setEntries($this->_results[intval($this->_conn->offset / $this->_conn->pageSize)]); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | Yii::endProfile($token, __METHOD__); |
| 145 | 145 | |
| 146 | - $token = 'Get Attributes of entries with limit pagination in ' . $this->_conn->pageSize; |
|
| 146 | + $token = 'Get Attributes of entries with limit pagination in '.$this->_conn->pageSize; |
|
| 147 | 147 | Yii::beginProfile($token, __METHOD__); |
| 148 | 148 | $data = []; |
| 149 | 149 | foreach ($this as $item) { |