PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.6.1
Defender Security – Malware Scanner, Login Security & Firewall v5.6.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 5.6.1, at vendor/thecodingmachine/safe/generated/ldap.php

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