1 | <?php |
||
22 | class Connection extends Component |
||
23 | { |
||
24 | /** |
||
25 | * LDAP protocol string. |
||
26 | * @var string |
||
27 | */ |
||
28 | const PROTOCOL = 'ldap://'; |
||
29 | |||
30 | /** |
||
31 | * LDAP port number. |
||
32 | * @var string |
||
33 | */ |
||
34 | const PORT = '389'; |
||
35 | |||
36 | /** |
||
37 | * @event Event an event that is triggered after a DB connection is established |
||
38 | */ |
||
39 | const EVENT_AFTER_OPEN = 'afterOpen'; |
||
40 | |||
41 | /** |
||
42 | * @var string the LDAP base dn. |
||
43 | */ |
||
44 | public $baseDn; |
||
45 | |||
46 | /** |
||
47 | * https://msdn.microsoft.com/en-us/library/ms677913(v=vs.85).aspx |
||
48 | * @var bool the integer to instruct the LDAP connection whether or not to follow referrals. |
||
49 | */ |
||
50 | public $followReferrals = false; |
||
51 | |||
52 | /** |
||
53 | * @var string The LDAP port to use when connecting to the domain controllers. |
||
54 | */ |
||
55 | public $port = self::PORT; |
||
56 | |||
57 | /** |
||
58 | * @var bool Determines whether or not to use TLS with the current LDAP connection. |
||
59 | */ |
||
60 | public $useTLS = false; |
||
61 | |||
62 | /** |
||
63 | * @var array the domain controllers to connect to. |
||
64 | */ |
||
65 | public $dc = []; |
||
66 | |||
67 | /** |
||
68 | * @var string the username for establishing LDAP connection. Defaults to `null` meaning no username to use. |
||
69 | */ |
||
70 | public $username; |
||
71 | |||
72 | /** |
||
73 | * @var string the password for establishing DB connection. Defaults to `null` meaning no password to use. |
||
74 | */ |
||
75 | public $password; |
||
76 | |||
77 | /** |
||
78 | * @var int The page size for the paging operation. |
||
79 | */ |
||
80 | public $pageSize = -1; |
||
81 | |||
82 | /** |
||
83 | * @var integer zero-based offset from where the records are to be returned. If not set or |
||
84 | * less than 1, it means not filter values. |
||
85 | */ |
||
86 | public $offset = -1; |
||
87 | |||
88 | /** |
||
89 | * @var boolean whether to enable caching. |
||
90 | * Note that in order to enable truly caching, a valid cache component as specified |
||
91 | * by [[cache]] must be enabled and [[enableCache]] must be set true. |
||
92 | * @see cacheDuration |
||
93 | * @see cache |
||
94 | */ |
||
95 | public $enableCache = false; |
||
96 | |||
97 | /** |
||
98 | * @var integer number of seconds that table metadata can remain valid in cache. |
||
99 | * Use 0 to indicate that the cached data will never expire. |
||
100 | * @see enableCache |
||
101 | */ |
||
102 | public $cacheDuration = 3600; |
||
103 | |||
104 | /** |
||
105 | * @var Cache|string the cache object or the ID of the cache application component that |
||
106 | * is used to cache result query. |
||
107 | * @see enableCache |
||
108 | */ |
||
109 | public $cache = 'cache'; |
||
110 | |||
111 | /** |
||
112 | * @var string the LDAP account suffix. |
||
113 | */ |
||
114 | protected $accountSuffix; |
||
115 | |||
116 | /** |
||
117 | * @var string the LDAP account prefix. |
||
118 | */ |
||
119 | protected $accountPrefix; |
||
120 | |||
121 | /** |
||
122 | * @var bool stores the bool whether or not the current connection is bound. |
||
123 | */ |
||
124 | protected $_bound = false; |
||
125 | |||
126 | /** |
||
127 | * @var resource|false |
||
128 | */ |
||
129 | protected $resource; |
||
130 | |||
131 | |||
132 | /** |
||
133 | * Connects and Binds to the Domain Controller with a administrator credentials. |
||
134 | * @return void |
||
135 | */ |
||
136 | protected function open($anonymous = false) |
||
147 | |||
148 | /** |
||
149 | * Connection. |
||
150 | * @param string|array $hostname |
||
151 | * @param type $port |
||
152 | * @return void |
||
153 | */ |
||
154 | public function connect($hostname = [], $port = '389') |
||
171 | |||
172 | /** |
||
173 | * Closes the current connection. |
||
174 | * |
||
175 | * @return boolean |
||
176 | */ |
||
177 | public function close() |
||
184 | |||
185 | /** |
||
186 | * Execute ldap functions like. |
||
187 | * |
||
188 | * http://php.net/manual/en/ref.ldap.php |
||
189 | * |
||
190 | * @param string $function php LDAP function |
||
191 | * @param array $params params for execute ldap function |
||
192 | * @return bool|DataReader |
||
193 | */ |
||
194 | public function executeQuery($function, $params) |
||
215 | |||
216 | /** |
||
217 | * Execute ldap functions like. |
||
218 | * |
||
219 | * http://php.net/manual/en/ref.ldap.php |
||
220 | * |
||
221 | * @param string $function php LDAP function |
||
222 | * @param array $params params for execute ldap function |
||
223 | * @return bool|DataReader |
||
224 | */ |
||
225 | public function execute($function, $params) |
||
233 | |||
234 | /** |
||
235 | * Returns true/false if the current connection is bound. |
||
236 | * @return bool |
||
237 | */ |
||
238 | public function getBound() |
||
242 | |||
243 | /** |
||
244 | * Get the current resource of connection. |
||
245 | * @return resource |
||
246 | */ |
||
247 | public function getResource() |
||
251 | |||
252 | /** |
||
253 | * Sorts an AD search result by the specified attribute. |
||
254 | * @param resource $result |
||
255 | * @param string $attribute |
||
256 | * @return bool |
||
257 | */ |
||
258 | public function sort($result, $attribute) |
||
262 | |||
263 | /** |
||
264 | * Adds an entry to the current connection. |
||
265 | * @param string $dn |
||
266 | * @param array $entry |
||
267 | * @return bool |
||
268 | */ |
||
269 | public function add($dn, array $entry) |
||
273 | |||
274 | /** |
||
275 | * Deletes an entry on the current connection. |
||
276 | * @param string $dn |
||
277 | * @return bool |
||
278 | */ |
||
279 | public function delete($dn) |
||
283 | |||
284 | /** |
||
285 | * Modify the name of an entry on the current connection. |
||
286 | * |
||
287 | * @param string $dn |
||
288 | * @param string $newRdn |
||
289 | * @param string $newParent |
||
290 | * @param bool $deleteOldRdn |
||
291 | * @return bool |
||
292 | */ |
||
293 | public function rename($dn, $newRdn, $newParent, $deleteOldRdn = false) |
||
297 | |||
298 | /** |
||
299 | * Modifies an existing entry on the |
||
300 | * current connection. |
||
301 | * @param string $dn |
||
302 | * @param array $entry |
||
303 | * @return bool |
||
304 | */ |
||
305 | public function modify($dn, array $entry) |
||
309 | |||
310 | /** |
||
311 | * Batch modifies an existing entry on the current connection. |
||
312 | * @param string $dn |
||
313 | * @param array $values |
||
314 | * @return mixed |
||
315 | */ |
||
316 | public function modifyBatch($dn, array $values) |
||
320 | |||
321 | /** |
||
322 | * Add attribute values to current attributes. |
||
323 | * @param string $dn |
||
324 | * @param array $entry |
||
325 | * @return boolean |
||
326 | */ |
||
327 | public function modAdd($dn, array $entry) |
||
331 | |||
332 | /** |
||
333 | * Replaces attribute values with new ones. |
||
334 | * @param string $dn |
||
335 | * @param array $entry |
||
336 | * @return boolean |
||
337 | */ |
||
338 | public function modReplace($dn, array $entry) |
||
342 | |||
343 | /** |
||
344 | * Delete attribute values from current attributes. |
||
345 | * @param string $dn |
||
346 | * @param array $entry |
||
347 | * @return boolean |
||
348 | */ |
||
349 | public function modDelete($dn, array $entry) |
||
353 | |||
354 | /** |
||
355 | * Retrieve the entries from a search result. |
||
356 | * @param resource $searchResult |
||
357 | * @return array|boolean |
||
358 | */ |
||
359 | public function getEntries($searchResult) |
||
363 | |||
364 | /** |
||
365 | * Returns the number of entries from a search result. |
||
366 | * @param resource $searchResult |
||
367 | * @return int |
||
368 | */ |
||
369 | public function countEntries($searchResult) |
||
373 | |||
374 | /** |
||
375 | * Retrieves the first entry from a search result. |
||
376 | * @param resource $searchResult |
||
377 | * @return resource |
||
378 | */ |
||
379 | public function getFirstEntry($searchResult) |
||
383 | |||
384 | /** |
||
385 | * Retrieves the next entry from a search result. |
||
386 | * @param $entry |
||
387 | * @return resource |
||
388 | */ |
||
389 | public function getNextEntry($entry) |
||
393 | |||
394 | /** |
||
395 | * Retrieves the ldap entry's attributes. |
||
396 | * @param $entry |
||
397 | * @return mixed |
||
398 | */ |
||
399 | public function getAttributes($entry) |
||
403 | |||
404 | /** |
||
405 | * Sets an option on the current connection. |
||
406 | * @param int $option |
||
407 | * @param mixed $value |
||
408 | * @return boolean |
||
409 | */ |
||
410 | public function setOption($option, $value) |
||
414 | |||
415 | /** |
||
416 | * Starts a connection using TLS. |
||
417 | * @return bool |
||
418 | */ |
||
419 | public function startTLS() |
||
423 | |||
424 | /** |
||
425 | * Send LDAP pagination control. |
||
426 | * |
||
427 | * @param int $pageSize |
||
|
|||
428 | * @param bool $isCritical |
||
429 | * @param string $cookie |
||
430 | * @return bool |
||
431 | */ |
||
432 | public function setControlPagedResult($cookie) |
||
437 | |||
438 | /** |
||
439 | * Retrieve a paginated result response. |
||
440 | * |
||
441 | * @param resource $result |
||
442 | * @param string $cookie |
||
443 | * @return bool |
||
444 | */ |
||
445 | public function setControlPagedResultResponse($result, &$cookie) |
||
449 | |||
450 | /** |
||
451 | * Retrieve the last error on the current connection. |
||
452 | * @return string |
||
453 | */ |
||
454 | public function getLastError() |
||
458 | |||
459 | /** |
||
460 | * Returns the number of the last error on the current connection. |
||
461 | * @return int |
||
462 | */ |
||
463 | public function getErrNo() |
||
467 | |||
468 | /** |
||
469 | * Returns the error string of the specified error number. |
||
470 | * @param int $number |
||
471 | * @return string |
||
472 | */ |
||
473 | public function err2Str($number) |
||
477 | } |
||
478 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.