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