PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.0.1
Defender Security – Malware Scanner, Login Security & Firewall v6.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / ldap.php

ldap.php in Defender Security – Malware Scanner, Login Security & Firewall 6.0.1, at vendor/thecodingmachine/safe/generated/ldap.php

1,624 lines 47.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\LdapException;
6
7 /**
8 * Does the same thing as ldap_add but returns the LDAP result resource to be parsed with ldap_parse_result.
9 *
10 * @param resource $link_identifier
11 * @param string $dn
12 * @param array $entry
13 * @param array|null $serverctrls
14 *
15 * @return resource Returns an LDAP result identifier.
16 * @throws LdapException
17 *
18 */
19 function ldap_add_ext($link_identifier, string $dn, array $entry, ?array $serverctrls = null)
20 {
21 error_clear_last();
22 $result = \ldap_add_ext($link_identifier, $dn, $entry, $serverctrls);
23 if ($result === false) {
24 throw LdapException::createFromPhpError();
25 }
26 return $result;
27 }
28
29
30 /**
31 * Add entries in the LDAP directory.
32 *
33 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
34 * @param string $dn The distinguished name of an LDAP entity.
35 * @param array $entry An array that specifies the information about the entry. The values in
36 * the entries are indexed by individual attributes.
37 * In case of multiple values for an attribute, they are indexed using
38 * integers starting with 0.
39 *
40 *
41 *
42 * ]]>
43 *
44 *
45 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
46 *
47 * @throws LdapException
48 *
49 */
50 function ldap_add($link_identifier, string $dn, array $entry, ?array $serverctrls = null): void
51 {
52 error_clear_last();
53 $result = \ldap_add($link_identifier, $dn, $entry, $serverctrls);
54 if ($result === false) {
55 throw LdapException::createFromPhpError();
56 }
57 }
58
59
60 /**
61 * Does the same thing as ldap_bind but returns the LDAP result resource to be parsed with ldap_parse_result.
62 *
63 * @param resource $link_identifier
64 * @param string|null $bind_rdn
65 * @param string|null $bind_password
66 * @param array|null $serverctrls
67 *
68 * @return resource Returns an LDAP result identifier.
69 * @throws LdapException
70 *
71 */
72 function ldap_bind_ext($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null, ?array $serverctrls = null)
73 {
74 error_clear_last();
75 $result = \ldap_bind_ext($link_identifier, $bind_rdn, $bind_password, $serverctrls);
76 if ($result === false) {
77 throw LdapException::createFromPhpError();
78 }
79 return $result;
80 }
81
82
83 /**
84 * Binds to the LDAP directory with specified RDN and password.
85 *
86 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
87 * @param string|null $bind_rdn
88 * @param string|null $bind_password
89 * @throws LdapException
90 *
91 */
92 function ldap_bind($link_identifier, ?string $bind_rdn = null, ?string $bind_password = null): void
93 {
94 error_clear_last();
95 $result = \ldap_bind($link_identifier, $bind_rdn, $bind_password);
96 if ($result === false) {
97 throw LdapException::createFromPhpError();
98 }
99 }
100
101
102 /**
103 * Retrieve the pagination information send by the server.
104 *
105 * @param resource $link An LDAP link identifier, returned by ldap_connect.
106 * @param resource $result
107 * @param string|null $cookie An opaque structure sent by the server.
108 * @param int|null $estimated The estimated number of entries to retrieve.
109 * @throws LdapException
110 *
111 */
112 function ldap_control_paged_result_response($link, $result, ?string &$cookie = null, ?int &$estimated = null): void
113 {
114 error_clear_last();
115 $result = \ldap_control_paged_result_response($link, $result, $cookie, $estimated);
116 if ($result === false) {
117 throw LdapException::createFromPhpError();
118 }
119 }
120
121
122 /**
123 * Enable LDAP pagination by sending the pagination control (page size, cookie...).
124 *
125 * @param resource $link An LDAP link identifier, returned by ldap_connect.
126 * @param int $pagesize The number of entries by page.
127 * @param bool $iscritical Indicates whether the pagination is critical or not.
128 * If true and if the server doesn't support pagination, the search
129 * will return no result.
130 * @param string $cookie An opaque structure sent by the server
131 * (ldap_control_paged_result_response).
132 * @throws LdapException
133 *
134 */
135 function ldap_control_paged_result($link, int $pagesize, bool $iscritical = false, string $cookie = ""): void
136 {
137 error_clear_last();
138 $result = \ldap_control_paged_result($link, $pagesize, $iscritical, $cookie);
139 if ($result === false) {
140 throw LdapException::createFromPhpError();
141 }
142 }
143
144
145 /**
146 * Returns the number of entries stored in the result of previous search
147 * operations.
148 *
149 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
150 * @param resource $result_identifier The internal LDAP result.
151 * @return int Returns number of entries in the result.
152 * @throws LdapException
153 *
154 */
155 function ldap_count_entries($link_identifier, $result_identifier): int
156 {
157 error_clear_last();
158 $result = \ldap_count_entries($link_identifier, $result_identifier);
159 if ($result === false) {
160 throw LdapException::createFromPhpError();
161 }
162 return $result;
163 }
164
165
166 /**
167 * Does the same thing as ldap_delete but returns the LDAP result resource to be parsed with ldap_parse_result.
168 *
169 * @param resource $link_identifier
170 * @param string $dn
171 * @param array|null $serverctrls
172 *
173 * @return resource Returns an LDAP result identifier.
174 * @throws LdapException
175 *
176 */
177 function ldap_delete_ext($link_identifier, string $dn, ?array $serverctrls = null)
178 {
179 error_clear_last();
180 $result = \ldap_delete_ext($link_identifier, $dn, $serverctrls);
181 if ($result === false) {
182 throw LdapException::createFromPhpError();
183 }
184 return $result;
185 }
186
187
188 /**
189 * Deletes a particular entry in LDAP directory.
190 *
191 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
192 * @param string $dn The distinguished name of an LDAP entity.
193 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
194 *
195 * @throws LdapException
196 *
197 */
198 function ldap_delete($link_identifier, string $dn, ?array $serverctrls = null): void
199 {
200 error_clear_last();
201 $result = \ldap_delete($link_identifier, $dn, $serverctrls);
202 if ($result === false) {
203 throw LdapException::createFromPhpError();
204 }
205 }
206
207
208 /**
209 * Performs a PASSWD extended operation.
210 *
211 * @param resource $link An LDAP link identifier, returned by ldap_connect.
212 * @param string $user dn of the user to change the password of.
213 * @param string $oldpw The old password of this user. May be ommited depending of server configuration.
214 * @param string $newpw The new password for this user. May be omitted or empty to have a generated password.
215 * @param array|null $serverctrls If provided, a password policy request control is send with the request and this is
216 * filled with an array of LDAP Controls
217 * returned with the request.
218 *
219 * @return mixed Returns the generated password if newpw is empty or omitted.
220 * Otherwise returns TRUE on success.
221 * @throws LdapException
222 *
223 */
224 function ldap_exop_passwd($link, string $user = "", string $oldpw = "", string $newpw = "", ?array &$serverctrls = null)
225 {
226 error_clear_last();
227 $result = \ldap_exop_passwd($link, $user, $oldpw, $newpw, $serverctrls);
228 if ($result === false) {
229 throw LdapException::createFromPhpError();
230 }
231 return $result;
232 }
233
234
235 /**
236 * Performs a WHOAMI extended operation and returns the data.
237 *
238 * @param resource $link An LDAP link identifier, returned by ldap_connect.
239 * @return string The data returned by the server.
240 * @throws LdapException
241 *
242 */
243 function ldap_exop_whoami($link): string
244 {
245 error_clear_last();
246 $result = \ldap_exop_whoami($link);
247 if ($result === false) {
248 throw LdapException::createFromPhpError();
249 }
250 return $result;
251 }
252
253
254 /**
255 * Performs an extended operation on the specified link with
256 * reqoid the OID of the operation and
257 * reqdata the data.
258 *
259 * @param resource $link An LDAP link identifier, returned by ldap_connect.
260 * @param string $reqoid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send.
261 * @param string|null $reqdata The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded.
262 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
263 * @param string|null $retdata Will be filled with the extended operation response data if provided.
264 * If not provided you may use ldap_parse_exop on the result object
265 * later to get this data.
266 * @param string|null $retoid Will be filled with the response OID if provided, usually equal to the request OID.
267 *
268 * @return mixed When used with retdata, returns TRUE on success.
269 * When used without retdata, returns a result identifier.
270 * @throws LdapException
271 *
272 */
273 function ldap_exop($link, string $reqoid, ?string $reqdata = null, ?array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null)
274 {
275 error_clear_last();
276 $result = \ldap_exop($link, $reqoid, $reqdata, $serverctrls, $retdata, $retoid);
277 if ($result === false) {
278 throw LdapException::createFromPhpError();
279 }
280 return $result;
281 }
282
283
284 /**
285 * Splits the DN returned by ldap_get_dn and breaks it
286 * up into its component parts. Each part is known as Relative Distinguished
287 * Name, or RDN.
288 *
289 * @param string $dn The distinguished name of an LDAP entity.
290 * @param int $with_attrib Used to request if the RDNs are returned with only values or their
291 * attributes as well. To get RDNs with the attributes (i.e. in
292 * attribute=value format) set with_attrib to 0
293 * and to get only values set it to 1.
294 * @return array Returns an array of all DN components.
295 * The first element in the array has count key and
296 * represents the number of returned values, next elements are numerically
297 * indexed DN components.
298 * @throws LdapException
299 *
300 */
301 function ldap_explode_dn(string $dn, int $with_attrib): array
302 {
303 error_clear_last();
304 $result = \ldap_explode_dn($dn, $with_attrib);
305 if ($result === false) {
306 throw LdapException::createFromPhpError();
307 }
308 return $result;
309 }
310
311
312 /**
313 * Gets the first attribute in the given entry. Remaining attributes are
314 * retrieved by calling ldap_next_attribute successively.
315 *
316 * Similar to reading entries, attributes are also read one by one from a
317 * particular entry.
318 *
319 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
320 * @param resource $result_entry_identifier
321 * @return string Returns the first attribute in the entry on success and FALSE on
322 * error.
323 * @throws LdapException
324 *
325 */
326 function ldap_first_attribute($link_identifier, $result_entry_identifier): string
327 {
328 error_clear_last();
329 $result = \ldap_first_attribute($link_identifier, $result_entry_identifier);
330 if ($result === false) {
331 throw LdapException::createFromPhpError();
332 }
333 return $result;
334 }
335
336
337 /**
338 * Returns the entry identifier for first entry in the result. This entry
339 * identifier is then supplied to ldap_next_entry
340 * routine to get successive entries from the result.
341 *
342 * Entries in the LDAP result are read sequentially using the
343 * ldap_first_entry and
344 * ldap_next_entry functions.
345 *
346 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
347 * @param resource $result_identifier
348 * @return resource Returns the result entry identifier for the first entry on success and
349 * FALSE on error.
350 * @throws LdapException
351 *
352 */
353 function ldap_first_entry($link_identifier, $result_identifier)
354 {
355 error_clear_last();
356 $result = \ldap_first_entry($link_identifier, $result_identifier);
357 if ($result === false) {
358 throw LdapException::createFromPhpError();
359 }
360 return $result;
361 }
362
363
364 /**
365 * Frees up the memory allocated internally to store the result. All result
366 * memory will be automatically freed when the script terminates.
367 *
368 * Typically all the memory allocated for the LDAP result gets freed at the
369 * end of the script. In case the script is making successive searches which
370 * return large result sets, ldap_free_result could be
371 * called to keep the runtime memory usage by the script low.
372 *
373 * @param resource $result_identifier
374 * @throws LdapException
375 *
376 */
377 function ldap_free_result($result_identifier): void
378 {
379 error_clear_last();
380 $result = \ldap_free_result($result_identifier);
381 if ($result === false) {
382 throw LdapException::createFromPhpError();
383 }
384 }
385
386
387 /**
388 * Reads attributes and values from an entry in the search result.
389 *
390 * Having located a specific entry in the directory, you can find out what
391 * information is held for that entry by using this call. You would use this
392 * call for an application which "browses" directory entries and/or where you
393 * do not know the structure of the directory entries. In many applications
394 * you will be searching for a specific attribute such as an email address or
395 * a surname, and won't care what other data is held.
396 *
397 *
398 *
399 *
400 *
401 *
402 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
403 * @param resource $result_entry_identifier
404 * @return array Returns a complete entry information in a multi-dimensional array
405 * on success and FALSE on error.
406 * @throws LdapException
407 *
408 */
409 function ldap_get_attributes($link_identifier, $result_entry_identifier): array
410 {
411 error_clear_last();
412 $result = \ldap_get_attributes($link_identifier, $result_entry_identifier);
413 if ($result === false) {
414 throw LdapException::createFromPhpError();
415 }
416 return $result;
417 }
418
419
420 /**
421 * Finds out the DN of an entry in the result.
422 *
423 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
424 * @param resource $result_entry_identifier
425 * @return string Returns the DN of the result entry and FALSE on error.
426 * @throws LdapException
427 *
428 */
429 function ldap_get_dn($link_identifier, $result_entry_identifier): string
430 {
431 error_clear_last();
432 $result = \ldap_get_dn($link_identifier, $result_entry_identifier);
433 if ($result === false) {
434 throw LdapException::createFromPhpError();
435 }
436 return $result;
437 }
438
439
440 /**
441 * Reads multiple entries from the given result, and then reading the
442 * attributes and multiple values.
443 *
444 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
445 * @param resource $result_identifier
446 * @return array Returns a complete result information in a multi-dimensional array on
447 * success and FALSE on error.
448 *
449 * The structure of the array is as follows.
450 * The attribute index is converted to lowercase. (Attributes are
451 * case-insensitive for directory servers, but not when used as
452 * array indices.)
453 *
454 *
455 *
456 *
457 *
458 * @throws LdapException
459 *
460 */
461 function ldap_get_entries($link_identifier, $result_identifier): array
462 {
463 error_clear_last();
464 $result = \ldap_get_entries($link_identifier, $result_identifier);
465 if ($result === false) {
466 throw LdapException::createFromPhpError();
467 }
468 return $result;
469 }
470
471
472 /**
473 * Sets retval to the value of the specified option.
474 *
475 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
476 * @param int $option The parameter option can be one of:
477 *
478 *
479 *
480 *
481 * Option
482 * Type
483 * since
484 *
485 *
486 *
487 *
488 * LDAP_OPT_DEREF
489 * integer
490 *
491 *
492 *
493 * LDAP_OPT_SIZELIMIT
494 * integer
495 *
496 *
497 *
498 * LDAP_OPT_TIMELIMIT
499 * integer
500 *
501 *
502 *
503 * LDAP_OPT_NETWORK_TIMEOUT
504 * integer
505 *
506 *
507 *
508 * LDAP_OPT_PROTOCOL_VERSION
509 * integer
510 *
511 *
512 *
513 * LDAP_OPT_ERROR_NUMBER
514 * integer
515 *
516 *
517 *
518 * LDAP_OPT_DIAGNOSTIC_MESSAGE
519 * integer
520 *
521 *
522 *
523 * LDAP_OPT_REFERRALS
524 * bool
525 *
526 *
527 *
528 * LDAP_OPT_RESTART
529 * bool
530 *
531 *
532 *
533 * LDAP_OPT_HOST_NAME
534 * string
535 *
536 *
537 *
538 * LDAP_OPT_ERROR_STRING
539 * string
540 *
541 *
542 *
543 * LDAP_OPT_MATCHED_DN
544 * string
545 *
546 *
547 *
548 * LDAP_OPT_SERVER_CONTROLS
549 * array
550 *
551 *
552 *
553 * LDAP_OPT_CLIENT_CONTROLS
554 * array
555 *
556 *
557 *
558 * LDAP_OPT_X_KEEPALIVE_IDLE
559 * int
560 * 7.1
561 *
562 *
563 * LDAP_OPT_X_KEEPALIVE_PROBES
564 * int
565 * 7.1
566 *
567 *
568 * LDAP_OPT_X_KEEPALIVE_INTERVAL
569 * int
570 * 7.1
571 *
572 *
573 * LDAP_OPT_X_TLS_CACERTDIR
574 * string
575 * 7.1
576 *
577 *
578 * LDAP_OPT_X_TLS_CACERTFILE
579 * string
580 * 7.1
581 *
582 *
583 * LDAP_OPT_X_TLS_CERTFILE
584 * string
585 * 7.1
586 *
587 *
588 * LDAP_OPT_X_TLS_CIPHER_SUITE
589 * string
590 * 7.1
591 *
592 *
593 * LDAP_OPT_X_TLS_CRLCHECK
594 * integer
595 * 7.1
596 *
597 *
598 * LDAP_OPT_X_TLS_CRL_NONE
599 * integer
600 * 7.1
601 *
602 *
603 * LDAP_OPT_X_TLS_CRL_PEER
604 * integer
605 * 7.1
606 *
607 *
608 * LDAP_OPT_X_TLS_CRL_ALL
609 * integer
610 * 7.1
611 *
612 *
613 * LDAP_OPT_X_TLS_CRLFILE
614 * string
615 * 7.1
616 *
617 *
618 * LDAP_OPT_X_TLS_DHFILE
619 * string
620 * 7.1
621 *
622 *
623 * LDAP_OPT_X_TLS_KEYILE
624 * string
625 * 7.1
626 *
627 *
628 * LDAP_OPT_X_TLS_PACKAGE
629 * string
630 * 7.1
631 *
632 *
633 * LDAP_OPT_X_TLS_PROTOCOL_MIN
634 * integer
635 * 7.1
636 *
637 *
638 * LDAP_OPT_X_TLS_RANDOM_FILE
639 * string
640 * 7.1
641 *
642 *
643 * LDAP_OPT_X_TLS_REQUIRE_CERT
644 * integer
645 *
646 *
647 *
648 *
649 *
650 * @param mixed $retval This will be set to the option value.
651 * @throws LdapException
652 *
653 */
654 function ldap_get_option($link_identifier, int $option, &$retval): void
655 {
656 error_clear_last();
657 $result = \ldap_get_option($link_identifier, $option, $retval);
658 if ($result === false) {
659 throw LdapException::createFromPhpError();
660 }
661 }
662
663
664 /**
665 * Reads all the values of the attribute in the entry in the result.
666 *
667 * This function is used exactly like ldap_get_values
668 * except that it handles binary data and not string data.
669 *
670 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
671 * @param resource $result_entry_identifier
672 * @param string $attribute
673 * @return array Returns an array of values for the attribute on success and FALSE on
674 * error. Individual values are accessed by integer index in the array. The
675 * first index is 0. The number of values can be found by indexing "count"
676 * in the resultant array.
677 * @throws LdapException
678 *
679 */
680 function ldap_get_values_len($link_identifier, $result_entry_identifier, string $attribute): array
681 {
682 error_clear_last();
683 $result = \ldap_get_values_len($link_identifier, $result_entry_identifier, $attribute);
684 if ($result === false) {
685 throw LdapException::createFromPhpError();
686 }
687 return $result;
688 }
689
690
691 /**
692 * Reads all the values of the attribute in the entry in the result.
693 *
694 * This call needs a result_entry_identifier,
695 * so needs to be preceded by one of the ldap search calls and one
696 * of the calls to get an individual entry.
697 *
698 * You application will either be hard coded to look for certain
699 * attributes (such as "surname" or "mail") or you will have to use
700 * the ldap_get_attributes call to work out
701 * what attributes exist for a given entry.
702 *
703 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
704 * @param resource $result_entry_identifier
705 * @param string $attribute
706 * @return array Returns an array of values for the attribute on success and FALSE on
707 * error. The number of values can be found by indexing "count" in the
708 * resultant array. Individual values are accessed by integer index in the
709 * array. The first index is 0.
710 *
711 * LDAP allows more than one entry for an attribute, so it can, for example,
712 * store a number of email addresses for one person's directory entry all
713 * labeled with the attribute "mail"
714 *
715 *
716 * return_value["count"] = number of values for attribute
717 * return_value[0] = first value of attribute
718 * return_value[i] = ith value of attribute
719 *
720 *
721 * @throws LdapException
722 *
723 */
724 function ldap_get_values($link_identifier, $result_entry_identifier, string $attribute): array
725 {
726 error_clear_last();
727 $result = \ldap_get_values($link_identifier, $result_entry_identifier, $attribute);
728 if ($result === false) {
729 throw LdapException::createFromPhpError();
730 }
731 return $result;
732 }
733
734
735 /**
736 * Performs the search for a specified filter on the
737 * directory with the scope LDAP_SCOPE_ONELEVEL.
738 *
739 * LDAP_SCOPE_ONELEVEL means that the search should only
740 * return information that is at the level immediately below the
741 * base_dn given in the call.
742 * (Equivalent to typing "ls" and getting a list of files and folders in the
743 * current working directory.)
744 *
745 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
746 * @param string $base_dn The base DN for the directory.
747 * @param string $filter
748 * @param array|null $attributes An array of the required attributes, e.g. array("mail", "sn", "cn").
749 * Note that the "dn" is always returned irrespective of which attributes
750 * types are requested.
751 *
752 * Using this parameter is much more efficient than the default action
753 * (which is to return all attributes and their associated values).
754 * The use of this parameter should therefore be considered good
755 * practice.
756 * @param int $attrsonly Should be set to 1 if only attribute types are wanted. If set to 0
757 * both attributes types and attribute values are fetched which is the
758 * default behaviour.
759 * @param int $sizelimit Enables you to limit the count of entries fetched. Setting this to 0
760 * means no limit.
761 *
762 * This parameter can NOT override server-side preset sizelimit. You can
763 * set it lower though.
764 *
765 * Some directory server hosts will be configured to return no more than
766 * a preset number of entries. If this occurs, the server will indicate
767 * that it has only returned a partial results set. This also occurs if
768 * you use this parameter to limit the count of fetched entries.
769 * @param int $timelimit Sets the number of seconds how long is spend on the search. Setting
770 * this to 0 means no limit.
771 *
772 * This parameter can NOT override server-side preset timelimit. You can
773 * set it lower though.
774 * @param int $deref Specifies how aliases should be handled during the search. It can be
775 * one of the following:
776 *
777 *
778 *
779 * LDAP_DEREF_NEVER - (default) aliases are never
780 * dereferenced.
781 *
782 *
783 *
784 *
785 * LDAP_DEREF_SEARCHING - aliases should be
786 * dereferenced during the search but not when locating the base object
787 * of the search.
788 *
789 *
790 *
791 *
792 * LDAP_DEREF_FINDING - aliases should be
793 * dereferenced when locating the base object but not during the search.
794 *
795 *
796 *
797 *
798 * LDAP_DEREF_ALWAYS - aliases should be dereferenced
799 * always.
800 *
801 *
802 *
803 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
804 *
805 * @return resource Returns a search result identifier.
806 * @throws LdapException
807 *
808 */
809 function ldap_list($link_identifier, string $base_dn, string $filter, ?array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $serverctrls = null)
810 {
811 error_clear_last();
812 if ($serverctrls !== null) {
813 $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
814 } elseif ($deref !== LDAP_DEREF_NEVER) {
815 $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
816 } elseif ($timelimit !== -1) {
817 $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit);
818 } elseif ($sizelimit !== -1) {
819 $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit);
820 } elseif ($attrsonly !== 0) {
821 $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes, $attrsonly);
822 } elseif ($attributes !== null) {
823 $result = \ldap_list($link_identifier, $base_dn, $filter, $attributes);
824 } else {
825 $result = \ldap_list($link_identifier, $base_dn, $filter);
826 }
827 if ($result === false) {
828 throw LdapException::createFromPhpError();
829 }
830 return $result;
831 }
832
833
834 /**
835 * Does the same thing as ldap_mod_add but returns the LDAP result resource to be parsed with ldap_parse_result.
836 *
837 * @param resource $link_identifier
838 * @param string $dn
839 * @param array $entry
840 * @param array|null $serverctrls
841 *
842 * @return resource Returns an LDAP result identifier.
843 * @throws LdapException
844 *
845 */
846 function ldap_mod_add_ext($link_identifier, string $dn, array $entry, ?array $serverctrls = null)
847 {
848 error_clear_last();
849 $result = \ldap_mod_add_ext($link_identifier, $dn, $entry, $serverctrls);
850 if ($result === false) {
851 throw LdapException::createFromPhpError();
852 }
853 return $result;
854 }
855
856
857 /**
858 * Adds one or more attribute values to the specified dn.
859 * To add a whole new object see ldap_add function.
860 *
861 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
862 * @param string $dn The distinguished name of an LDAP entity.
863 * @param array $entry An associative array listing the attirbute values to add. If an attribute was not existing yet it will be added. If an attribute is existing you can only add values to it if it supports multiple values.
864 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
865 *
866 * @throws LdapException
867 *
868 */
869 function ldap_mod_add($link_identifier, string $dn, array $entry, ?array $serverctrls = null): void
870 {
871 error_clear_last();
872 $result = \ldap_mod_add($link_identifier, $dn, $entry, $serverctrls);
873 if ($result === false) {
874 throw LdapException::createFromPhpError();
875 }
876 }
877
878
879 /**
880 * Does the same thing as ldap_mod_del but returns the LDAP result resource to be parsed with ldap_parse_result.
881 *
882 * @param resource $link_identifier
883 * @param string $dn
884 * @param array $entry
885 * @param array|null $serverctrls
886 *
887 * @return resource Returns an LDAP result identifier.
888 * @throws LdapException
889 *
890 */
891 function ldap_mod_del_ext($link_identifier, string $dn, array $entry, ?array $serverctrls = null)
892 {
893 error_clear_last();
894 $result = \ldap_mod_del_ext($link_identifier, $dn, $entry, $serverctrls);
895 if ($result === false) {
896 throw LdapException::createFromPhpError();
897 }
898 return $result;
899 }
900
901
902 /**
903 * Removes one or more attribute values from the specified dn.
904 * Object deletions are done by the
905 * ldap_delete function.
906 *
907 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
908 * @param string $dn The distinguished name of an LDAP entity.
909 * @param array $entry
910 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
911 *
912 * @throws LdapException
913 *
914 */
915 function ldap_mod_del($link_identifier, string $dn, array $entry, ?array $serverctrls = null): void
916 {
917 error_clear_last();
918 $result = \ldap_mod_del($link_identifier, $dn, $entry, $serverctrls);
919 if ($result === false) {
920 throw LdapException::createFromPhpError();
921 }
922 }
923
924
925 /**
926 * Does the same thing as ldap_mod_replace but returns the LDAP result resource to be parsed with ldap_parse_result.
927 *
928 * @param resource $link_identifier
929 * @param string $dn
930 * @param array $entry
931 * @param array|null $serverctrls
932 *
933 * @return resource Returns an LDAP result identifier.
934 * @throws LdapException
935 *
936 */
937 function ldap_mod_replace_ext($link_identifier, string $dn, array $entry, ?array $serverctrls = null)
938 {
939 error_clear_last();
940 $result = \ldap_mod_replace_ext($link_identifier, $dn, $entry, $serverctrls);
941 if ($result === false) {
942 throw LdapException::createFromPhpError();
943 }
944 return $result;
945 }
946
947
948 /**
949 * Replaces one or more attributes from the specified dn.
950 * It may also add or remove attributes.
951 *
952 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
953 * @param string $dn The distinguished name of an LDAP entity.
954 * @param array $entry An associative array listing the attributes to replace. Sending an empty array as value will remove the attribute, while sending an attribute not existing yet on this entry will add it.
955 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
956 *
957 * @throws LdapException
958 *
959 */
960 function ldap_mod_replace($link_identifier, string $dn, array $entry, ?array $serverctrls = null): void
961 {
962 error_clear_last();
963 $result = \ldap_mod_replace($link_identifier, $dn, $entry, $serverctrls);
964 if ($result === false) {
965 throw LdapException::createFromPhpError();
966 }
967 }
968
969
970 /**
971 * Modifies an existing entry in the LDAP directory. Allows detailed
972 * specification of the modifications to perform.
973 *
974 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
975 * @param string $dn The distinguished name of an LDAP entity.
976 * @param array $entry An array that specifies the modifications to make. Each entry in this
977 * array is an associative array with two or three keys:
978 * attrib maps to the name of the attribute to modify,
979 * modtype maps to the type of modification to perform,
980 * and (depending on the type of modification) values
981 * maps to an array of attribute values relevant to the modification.
982 *
983 * Possible values for modtype include:
984 *
985 *
986 * LDAP_MODIFY_BATCH_ADD
987 *
988 *
989 * Each value specified through values is added (as
990 * an additional value) to the attribute named by
991 * attrib.
992 *
993 *
994 *
995 *
996 * LDAP_MODIFY_BATCH_REMOVE
997 *
998 *
999 * Each value specified through values is removed
1000 * from the attribute named by attrib. Any value of
1001 * the attribute not contained in the values array
1002 * will remain untouched.
1003 *
1004 *
1005 *
1006 *
1007 * LDAP_MODIFY_BATCH_REMOVE_ALL
1008 *
1009 *
1010 * All values are removed from the attribute named by
1011 * attrib. A values entry must
1012 * not be provided.
1013 *
1014 *
1015 *
1016 *
1017 * LDAP_MODIFY_BATCH_REPLACE
1018 *
1019 *
1020 * All current values of the attribute named by
1021 * attrib are replaced with the values specified
1022 * through values.
1023 *
1024 *
1025 *
1026 *
1027 *
1028 * Each value specified through values is added (as
1029 * an additional value) to the attribute named by
1030 * attrib.
1031 *
1032 * Each value specified through values is removed
1033 * from the attribute named by attrib. Any value of
1034 * the attribute not contained in the values array
1035 * will remain untouched.
1036 *
1037 * All values are removed from the attribute named by
1038 * attrib. A values entry must
1039 * not be provided.
1040 *
1041 * All current values of the attribute named by
1042 * attrib are replaced with the values specified
1043 * through values.
1044 *
1045 * Note that any value for attrib must be a string, any
1046 * value for values must be an array of strings, and
1047 * any value for modtype must be one of the
1048 * LDAP_MODIFY_BATCH_* constants listed above.
1049 * @param array|null $serverctrls Each value specified through values is added (as
1050 * an additional value) to the attribute named by
1051 * attrib.
1052 *
1053 * @throws LdapException
1054 *
1055 */
1056 function ldap_modify_batch($link_identifier, string $dn, array $entry, ?array $serverctrls = null): void
1057 {
1058 error_clear_last();
1059 $result = \ldap_modify_batch($link_identifier, $dn, $entry, $serverctrls);
1060 if ($result === false) {
1061 throw LdapException::createFromPhpError();
1062 }
1063 }
1064
1065
1066 /**
1067 * Retrieves the attributes in an entry. The first call to
1068 * ldap_next_attribute is made with the
1069 * result_entry_identifier returned from
1070 * ldap_first_attribute.
1071 *
1072 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
1073 * @param resource $result_entry_identifier
1074 * @return string Returns the next attribute in an entry on success and FALSE on
1075 * error.
1076 * @throws LdapException
1077 *
1078 */
1079 function ldap_next_attribute($link_identifier, $result_entry_identifier): string
1080 {
1081 error_clear_last();
1082 $result = \ldap_next_attribute($link_identifier, $result_entry_identifier);
1083 if ($result === false) {
1084 throw LdapException::createFromPhpError();
1085 }
1086 return $result;
1087 }
1088
1089
1090 /**
1091 * Parse LDAP extended operation data from result object result
1092 *
1093 * @param resource $link An LDAP link identifier, returned by ldap_connect.
1094 * @param resource $result An LDAP result resource, returned by ldap_exop.
1095 * @param string|null $retdata Will be filled by the response data.
1096 * @param string|null $retoid Will be filled by the response OID.
1097 * @throws LdapException
1098 *
1099 */
1100 function ldap_parse_exop($link, $result, ?string &$retdata = null, ?string &$retoid = null): void
1101 {
1102 error_clear_last();
1103 $result = \ldap_parse_exop($link, $result, $retdata, $retoid);
1104 if ($result === false) {
1105 throw LdapException::createFromPhpError();
1106 }
1107 }
1108
1109
1110 /**
1111 * Parses an LDAP search result.
1112 *
1113 * @param resource $link An LDAP link identifier, returned by ldap_connect.
1114 * @param resource $result An LDAP result resource, returned by ldap_list or
1115 * ldap_search.
1116 * @param int|null $errcode A reference to a variable that will be set to the LDAP error code in
1117 * the result, or 0 if no error occurred.
1118 * @param string|null $matcheddn A reference to a variable that will be set to a matched DN if one was
1119 * recognised within the request, otherwise it will be set to NULL.
1120 * @param string|null $errmsg A reference to a variable that will be set to the LDAP error message in
1121 * the result, or an empty string if no error occurred.
1122 * @param array|null $referrals A reference to a variable that will be set to an array set
1123 * to all of the referral strings in the result, or an empty array if no
1124 * referrals were returned.
1125 * @param array|null $serverctrls An array of LDAP Controls which have been sent with the response.
1126 * @throws LdapException
1127 *
1128 */
1129 function ldap_parse_result($link, $result, ?int &$errcode, ?string &$matcheddn = null, ?string &$errmsg = null, ?array &$referrals = null, ?array &$serverctrls = null): void
1130 {
1131 error_clear_last();
1132 $result = \ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $serverctrls);
1133 if ($result === false) {
1134 throw LdapException::createFromPhpError();
1135 }
1136 }
1137
1138
1139 /**
1140 * Performs the search for a specified filter on the
1141 * directory with the scope LDAP_SCOPE_BASE. So it is
1142 * equivalent to reading an entry from the directory.
1143 *
1144 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
1145 * @param string $base_dn The base DN for the directory.
1146 * @param string $filter An empty filter is not allowed. If you want to retrieve absolutely all
1147 * information for this entry, use a filter of
1148 * objectClass=*. If you know which entry types are
1149 * used on the directory server, you might use an appropriate filter such
1150 * as objectClass=inetOrgPerson.
1151 * @param array|null $attributes An array of the required attributes, e.g. array("mail", "sn", "cn").
1152 * Note that the "dn" is always returned irrespective of which attributes
1153 * types are requested.
1154 *
1155 * Using this parameter is much more efficient than the default action
1156 * (which is to return all attributes and their associated values).
1157 * The use of this parameter should therefore be considered good
1158 * practice.
1159 * @param int $attrsonly Should be set to 1 if only attribute types are wanted. If set to 0
1160 * both attributes types and attribute values are fetched which is the
1161 * default behaviour.
1162 * @param int $sizelimit Enables you to limit the count of entries fetched. Setting this to 0
1163 * means no limit.
1164 *
1165 * This parameter can NOT override server-side preset sizelimit. You can
1166 * set it lower though.
1167 *
1168 * Some directory server hosts will be configured to return no more than
1169 * a preset number of entries. If this occurs, the server will indicate
1170 * that it has only returned a partial results set. This also occurs if
1171 * you use this parameter to limit the count of fetched entries.
1172 * @param int $timelimit Sets the number of seconds how long is spend on the search. Setting
1173 * this to 0 means no limit.
1174 *
1175 * This parameter can NOT override server-side preset timelimit. You can
1176 * set it lower though.
1177 * @param int $deref Specifies how aliases should be handled during the search. It can be
1178 * one of the following:
1179 *
1180 *
1181 *
1182 * LDAP_DEREF_NEVER - (default) aliases are never
1183 * dereferenced.
1184 *
1185 *
1186 *
1187 *
1188 * LDAP_DEREF_SEARCHING - aliases should be
1189 * dereferenced during the search but not when locating the base object
1190 * of the search.
1191 *
1192 *
1193 *
1194 *
1195 * LDAP_DEREF_FINDING - aliases should be
1196 * dereferenced when locating the base object but not during the search.
1197 *
1198 *
1199 *
1200 *
1201 * LDAP_DEREF_ALWAYS - aliases should be dereferenced
1202 * always.
1203 *
1204 *
1205 *
1206 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
1207 *
1208 * @return resource Returns a search result identifier.
1209 * @throws LdapException
1210 *
1211 */
1212 function ldap_read($link_identifier, string $base_dn, string $filter, ?array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $serverctrls = null)
1213 {
1214 error_clear_last();
1215 if ($serverctrls !== null) {
1216 $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
1217 } elseif ($deref !== LDAP_DEREF_NEVER) {
1218 $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
1219 } elseif ($timelimit !== -1) {
1220 $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit);
1221 } elseif ($sizelimit !== -1) {
1222 $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit);
1223 } elseif ($attrsonly !== 0) {
1224 $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes, $attrsonly);
1225 } elseif ($attributes !== null) {
1226 $result = \ldap_read($link_identifier, $base_dn, $filter, $attributes);
1227 } else {
1228 $result = \ldap_read($link_identifier, $base_dn, $filter);
1229 }
1230 if ($result === false) {
1231 throw LdapException::createFromPhpError();
1232 }
1233 return $result;
1234 }
1235
1236
1237 /**
1238 * Does the same thing as ldap_rename but returns the LDAP result resource to be parsed with ldap_parse_result.
1239 *
1240 * @param resource $link_identifier
1241 * @param string $dn
1242 * @param string $newrdn
1243 * @param string $newparent
1244 * @param bool $deleteoldrdn
1245 * @param array|null $serverctrls
1246 *
1247 * @return resource Returns an LDAP result identifier.
1248 * @throws LdapException
1249 *
1250 */
1251 function ldap_rename_ext($link_identifier, string $dn, string $newrdn, string $newparent, bool $deleteoldrdn, ?array $serverctrls = null)
1252 {
1253 error_clear_last();
1254 $result = \ldap_rename_ext($link_identifier, $dn, $newrdn, $newparent, $deleteoldrdn, $serverctrls);
1255 if ($result === false) {
1256 throw LdapException::createFromPhpError();
1257 }
1258 return $result;
1259 }
1260
1261
1262 /**
1263 * The entry specified by dn is renamed/moved.
1264 *
1265 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
1266 * @param string $dn The distinguished name of an LDAP entity.
1267 * @param string $newrdn The new RDN.
1268 * @param string $newparent The new parent/superior entry.
1269 * @param bool $deleteoldrdn If TRUE the old RDN value(s) is removed, else the old RDN value(s)
1270 * is retained as non-distinguished values of the entry.
1271 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
1272 *
1273 * @throws LdapException
1274 *
1275 */
1276 function ldap_rename($link_identifier, string $dn, string $newrdn, string $newparent, bool $deleteoldrdn, ?array $serverctrls = null): void
1277 {
1278 error_clear_last();
1279 $result = \ldap_rename($link_identifier, $dn, $newrdn, $newparent, $deleteoldrdn, $serverctrls);
1280 if ($result === false) {
1281 throw LdapException::createFromPhpError();
1282 }
1283 }
1284
1285
1286 /**
1287 *
1288 *
1289 * @param resource $link
1290 * @param string|null $binddn
1291 * @param string|null $password
1292 * @param string|null $sasl_mech
1293 * @param string|null $sasl_realm
1294 * @param string|null $sasl_authc_id
1295 * @param string|null $sasl_authz_id
1296 * @param string|null $props
1297 *
1298 * @throws LdapException
1299 *
1300 */
1301 function ldap_sasl_bind($link, ?string $binddn = null, ?string $password = null, ?string $sasl_mech = null, ?string $sasl_realm = null, ?string $sasl_authc_id = null, ?string $sasl_authz_id = null, ?string $props = null): void
1302 {
1303 error_clear_last();
1304 $result = \ldap_sasl_bind($link, $binddn, $password, $sasl_mech, $sasl_realm, $sasl_authc_id, $sasl_authz_id, $props);
1305 if ($result === false) {
1306 throw LdapException::createFromPhpError();
1307 }
1308 }
1309
1310
1311 /**
1312 * Performs the search for a specified filter on the directory with the scope
1313 * of LDAP_SCOPE_SUBTREE. This is equivalent to searching
1314 * the entire directory.
1315 *
1316 * From 4.0.5 on it's also possible to do parallel searches. To do this
1317 * you use an array of link identifiers, rather than a single identifier,
1318 * as the first argument. If you don't want the same base DN and the
1319 * same filter for all the searches, you can also use an array of base DNs
1320 * and/or an array of filters. Those arrays must be of the same size as
1321 * the link identifier array since the first entries of the arrays are
1322 * used for one search, the second entries are used for another, and so
1323 * on. When doing parallel searches an array of search result
1324 * identifiers is returned, except in case of error, then the entry
1325 * corresponding to the search will be FALSE. This is very much like
1326 * the value normally returned, except that a result identifier is always
1327 * returned when a search was made. There are some rare cases where the
1328 * normal search returns FALSE while the parallel search returns an
1329 * identifier.
1330 *
1331 * @param resource|array $link_identifier An LDAP link identifier, returned by ldap_connect.
1332 * @param string $base_dn The base DN for the directory.
1333 * @param string $filter The search filter can be simple or advanced, using boolean operators in
1334 * the format described in the LDAP documentation (see the Netscape Directory SDK or
1335 * RFC4515 for full
1336 * information on filters).
1337 * @param array|null $attributes An array of the required attributes, e.g. array("mail", "sn", "cn").
1338 * Note that the "dn" is always returned irrespective of which attributes
1339 * types are requested.
1340 *
1341 * Using this parameter is much more efficient than the default action
1342 * (which is to return all attributes and their associated values).
1343 * The use of this parameter should therefore be considered good
1344 * practice.
1345 * @param int $attrsonly Should be set to 1 if only attribute types are wanted. If set to 0
1346 * both attributes types and attribute values are fetched which is the
1347 * default behaviour.
1348 * @param int $sizelimit Enables you to limit the count of entries fetched. Setting this to 0
1349 * means no limit.
1350 *
1351 * This parameter can NOT override server-side preset sizelimit. You can
1352 * set it lower though.
1353 *
1354 * Some directory server hosts will be configured to return no more than
1355 * a preset number of entries. If this occurs, the server will indicate
1356 * that it has only returned a partial results set. This also occurs if
1357 * you use this parameter to limit the count of fetched entries.
1358 * @param int $timelimit Sets the number of seconds how long is spend on the search. Setting
1359 * this to 0 means no limit.
1360 *
1361 * This parameter can NOT override server-side preset timelimit. You can
1362 * set it lower though.
1363 * @param int $deref Specifies how aliases should be handled during the search. It can be
1364 * one of the following:
1365 *
1366 *
1367 *
1368 * LDAP_DEREF_NEVER - (default) aliases are never
1369 * dereferenced.
1370 *
1371 *
1372 *
1373 *
1374 * LDAP_DEREF_SEARCHING - aliases should be
1375 * dereferenced during the search but not when locating the base object
1376 * of the search.
1377 *
1378 *
1379 *
1380 *
1381 * LDAP_DEREF_FINDING - aliases should be
1382 * dereferenced when locating the base object but not during the search.
1383 *
1384 *
1385 *
1386 *
1387 * LDAP_DEREF_ALWAYS - aliases should be dereferenced
1388 * always.
1389 *
1390 *
1391 *
1392 * @param array|null $serverctrls Array of LDAP Controls to send with the request.
1393 *
1394 * @return resource Returns a search result identifier.
1395 * @throws LdapException
1396 *
1397 */
1398 function ldap_search($link_identifier, string $base_dn, string $filter, ?array $attributes = null, int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $serverctrls = null)
1399 {
1400 error_clear_last();
1401 if ($serverctrls !== null) {
1402 $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $serverctrls);
1403 } elseif ($deref !== LDAP_DEREF_NEVER) {
1404 $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref);
1405 } elseif ($timelimit !== -1) {
1406 $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit);
1407 } elseif ($sizelimit !== -1) {
1408 $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly, $sizelimit);
1409 } elseif ($attrsonly !== 0) {
1410 $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes, $attrsonly);
1411 } elseif ($attributes !== null) {
1412 $result = \ldap_search($link_identifier, $base_dn, $filter, $attributes);
1413 } else {
1414 $result = \ldap_search($link_identifier, $base_dn, $filter);
1415 }
1416 if ($result === false) {
1417 throw LdapException::createFromPhpError();
1418 }
1419 return $result;
1420 }
1421
1422
1423 /**
1424 * Sets the value of the specified option to be newval.
1425 *
1426 * @param resource|null $link_identifier An LDAP link identifier, returned by ldap_connect.
1427 * @param int $option The parameter option can be one of:
1428 *
1429 *
1430 *
1431 *
1432 * Option
1433 * Type
1434 * Available since
1435 *
1436 *
1437 *
1438 *
1439 * LDAP_OPT_DEREF
1440 * integer
1441 *
1442 *
1443 *
1444 * LDAP_OPT_SIZELIMIT
1445 * integer
1446 *
1447 *
1448 *
1449 * LDAP_OPT_TIMELIMIT
1450 * integer
1451 *
1452 *
1453 *
1454 * LDAP_OPT_NETWORK_TIMEOUT
1455 * integer
1456 * PHP 5.3.0
1457 *
1458 *
1459 * LDAP_OPT_PROTOCOL_VERSION
1460 * integer
1461 *
1462 *
1463 *
1464 * LDAP_OPT_ERROR_NUMBER
1465 * integer
1466 *
1467 *
1468 *
1469 * LDAP_OPT_REFERRALS
1470 * bool
1471 *
1472 *
1473 *
1474 * LDAP_OPT_RESTART
1475 * bool
1476 *
1477 *
1478 *
1479 * LDAP_OPT_HOST_NAME
1480 * string
1481 *
1482 *
1483 *
1484 * LDAP_OPT_ERROR_STRING
1485 * string
1486 *
1487 *
1488 *
1489 * LDAP_OPT_DIAGNOSTIC_MESSAGE
1490 * string
1491 *
1492 *
1493 *
1494 * LDAP_OPT_MATCHED_DN
1495 * string
1496 *
1497 *
1498 *
1499 * LDAP_OPT_SERVER_CONTROLS
1500 * array
1501 *
1502 *
1503 *
1504 * LDAP_OPT_CLIENT_CONTROLS
1505 * array
1506 *
1507 *
1508 *
1509 * LDAP_OPT_X_KEEPALIVE_IDLE
1510 * int
1511 * PHP 7.1.0
1512 *
1513 *
1514 * LDAP_OPT_X_KEEPALIVE_PROBES
1515 * int
1516 * PHP 7.1.0
1517 *
1518 *
1519 * LDAP_OPT_X_KEEPALIVE_INTERVAL
1520 * int
1521 * PHP 7.1.0
1522 *
1523 *
1524 * LDAP_OPT_X_TLS_CACERTDIR
1525 * string
1526 * PHP 7.1.0
1527 *
1528 *
1529 * LDAP_OPT_X_TLS_CACERTFILE
1530 * string
1531 * PHP 7.1.0
1532 *
1533 *
1534 * LDAP_OPT_X_TLS_CERTFILE
1535 * string
1536 * PHP 7.1.0
1537 *
1538 *
1539 * LDAP_OPT_X_TLS_CIPHER_SUITE
1540 * string
1541 * PHP 7.1.0
1542 *
1543 *
1544 * LDAP_OPT_X_TLS_CRLCHECK
1545 * integer
1546 * PHP 7.1.0
1547 *
1548 *
1549 * LDAP_OPT_X_TLS_CRLFILE
1550 * string
1551 * PHP 7.1.0
1552 *
1553 *
1554 * LDAP_OPT_X_TLS_DHFILE
1555 * string
1556 * PHP 7.1.0
1557 *
1558 *
1559 * LDAP_OPT_X_TLS_KEYFILE
1560 * string
1561 * PHP 7.1.0
1562 *
1563 *
1564 * LDAP_OPT_X_TLS_PROTOCOL_MIN
1565 * integer
1566 * PHP 7.1.0
1567 *
1568 *
1569 * LDAP_OPT_X_TLS_RANDOM_FILE
1570 * string
1571 * PHP 7.1.0
1572 *
1573 *
1574 * LDAP_OPT_X_TLS_REQUIRE_CERT
1575 * integer
1576 * PHP 7.0.5
1577 *
1578 *
1579 *
1580 *
1581 *
1582 * LDAP_OPT_SERVER_CONTROLS and
1583 * LDAP_OPT_CLIENT_CONTROLS require a list of
1584 * controls, this means that the value must be an array of controls. A
1585 * control consists of an oid identifying the control,
1586 * an optional value, and an optional flag for
1587 * criticality. In PHP a control is given by an
1588 * array containing an element with the key oid
1589 * and string value, and two optional elements. The optional
1590 * elements are key value with string value
1591 * and key iscritical with boolean value.
1592 * iscritical defaults to FALSE
1593 * if not supplied. See draft-ietf-ldapext-ldap-c-api-xx.txt
1594 * for details. See also the second example below.
1595 * @param mixed $newval The new value for the specified option.
1596 * @throws LdapException
1597 *
1598 */
1599 function ldap_set_option($link_identifier, int $option, $newval): void
1600 {
1601 error_clear_last();
1602 $result = \ldap_set_option($link_identifier, $option, $newval);
1603 if ($result === false) {
1604 throw LdapException::createFromPhpError();
1605 }
1606 }
1607
1608
1609 /**
1610 * Unbinds from the LDAP directory.
1611 *
1612 * @param resource $link_identifier An LDAP link identifier, returned by ldap_connect.
1613 * @throws LdapException
1614 *
1615 */
1616 function ldap_unbind($link_identifier): void
1617 {
1618 error_clear_last();
1619 $result = \ldap_unbind($link_identifier);
1620 if ($result === false) {
1621 throw LdapException::createFromPhpError();
1622 }
1623 }
1624