-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathLdapInterface.php
More file actions
631 lines (544 loc) · 16.1 KB
/
LdapInterface.php
File metadata and controls
631 lines (544 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<?php
namespace LdapRecord;
use LDAP\Connection;
use LDAP\Result;
/**
* @see https://ldap.com/ldap-oid-reference-guide
* @see http://msdn.microsoft.com/en-us/library/cc223359.aspx
* @see https://help.univention.com/t/openldap-debug-level/19301
*/
interface LdapInterface
{
/**
* The standard LDAP protocol string.
*
* @var string
*/
public const PROTOCOL = 'ldap://';
/**
* The TLS LDAP protocol string.
*
* @var string
*/
public const PROTOCOL_TLS = 'ldaps://';
/**
* The standard LDAP port number.
*
* @var int
*/
public const PORT = 389;
/**
* The LDAP SSL port number.
*
* @var int
*/
public const PORT_TLS = 636;
/**
* Print entry and exit from routines.
*
* @var int
*/
public const DEBUG_TRACE = 1;
/**
* Print packet activity.
*
* @var int
*/
public const DEBUG_PACKETS = 2;
/**
* Print data arguments from requests.
*
* @var int
*/
public const DEBUG_ARGS = 4;
/**
* Print connection activity.
*
* @var int
*/
public const DEBUG_CONNS = 8;
/**
* Print encoding and decoding of data.
*
* @var int
*/
public const DEBUG_BER = 16;
/**
* Print search filters.
*
* @var int
*/
public const DEBUG_FILTER = 32;
/**
* Print configuration file processing.
*
* @var int
*/
public const DEBUG_CONFIG = 64;
/**
* Print Access Control List activities.
*
* @var int
*/
public const DEBUG_ACL = 128;
/**
* Print operational statistics.
*
* @var int
*/
public const DEBUG_STATS = 256;
/**
* Print more detailed statistics.
*
* @var int
*/
public const DEBUG_STATS2 = 512;
/**
* Print communication with shell backends.
*
* @var int
*/
public const DEBUG_SHELL = 1024;
/**
* Print entry parsing.
*
* @var int
*/
public const DEBUG_PARSE = 2048;
/**
* Print LDAPSync replication.
*
* @var int
*/
public const DEBUG_SYNC = 16384;
/**
* Print referral activities.
*
* @var int
*/
public const DEBUG_REFERRAL = 32768;
/**
* Print error conditions.
*
* @var int
*/
public const DEBUG_ERROR = 32768;
/**
* Print all levels of debug.
*
* @var int
*/
public const DEBUG_ANY = 65535;
/**
* OID for StartTLS extended operation. Signals the server to initiate a TLS connection.
*
* @var string
*/
public const OID_SERVER_START_TLS = '1.3.6.1.4.1.1466.20037';
/**
* OID for Paged Results Control. Used to retrieve search results in pages.
*
* @var string
*/
public const OID_SERVER_PAGED_RESULTS = '1.2.840.113556.1.4.319';
/**
* OID for Show Deleted Control. Includes deleted entries in the search results.
*
* @var string
*/
public const OID_SERVER_SHOW_DELETED = '1.2.840.113556.1.4.417';
/**
* OID for Server Side Sort Control. Requests the server to sort the search results.
*
* @var string
*/
public const OID_SERVER_SORT = '1.2.840.113556.1.4.473';
/**
* OID for Cross-Domain Move Target Control. Used in cross-domain move operations.
*
* @var string
*/
public const OID_SERVER_CROSSDOM_MOVE_TARGET = '1.2.840.113556.1.4.521';
/**
* OID for LDAP Notification Control. Used to register for change notifications.
*
* @var string
*/
public const OID_SERVER_NOTIFICATION = '1.2.840.113556.1.4.528';
/**
* OID for Extended DN Control. Requests extended DN information in search results.
*
* @var string
*/
public const OID_SERVER_EXTENDED_DN = '1.2.840.113556.1.4.529';
/**
* OID for Lazy Commit Control. Delays the actual commit of changes until requested.
*
* @var string
*/
public const OID_SERVER_LAZY_COMMIT = '1.2.840.113556.1.4.619';
/**
* OID for Security Descriptor Flags Control. Used to manipulate security descriptor flags.
*
* @var string
*/
public const OID_SERVER_SD_FLAGS = '1.2.840.113556.1.4.801';
/**
* OID for Tree Delete Control. Enables the deletion of an entire subtree.
*
* @var string
*/
public const OID_SERVER_TREE_DELETE = '1.2.840.113556.1.4.805';
/**
* OID for DirSync Control. Used for directory synchronization operations.
*
* @var string
*/
public const OID_SERVER_DIRSYNC = '1.2.840.113556.1.4.841';
/**
* OID for Verify Name Control. Allows verification of an entry without retrieving attributes.
*
* @var string
*/
public const OID_SERVER_VERIFY_NAME = '1.2.840.113556.1.4.1338';
/**
* OID for Domain Scope Control. Limits a search to the current domain.
*
* @var string
*/
public const OID_SERVER_DOMAIN_SCOPE = '1.2.840.113556.1.4.1339';
/**
* OID for Search Options Control. Used to set various search options.
*
* @var string
*/
public const OID_SERVER_SEARCH_OPTIONS = '1.2.840.113556.1.4.1340';
/**
* OID for Permissive Modify Control. Allows modifications even if some attributes are missing.
*
* @var string
*/
public const OID_SERVER_PERMISSIVE_MODIFY = '1.2.840.113556.1.4.1413';
/**
* OID for Authentication Service Queries (ASQ) Control. Used to perform ASQ operations.
*
* @var string
*/
public const OID_SERVER_ASQ = '1.2.840.113556.1.4.1504';
/**
* OID for Fast Bind Control. Optimizes the bind process for faster authentication.
*
* @var string
*/
public const OID_SERVER_FAST_BIND = '1.2.840.113556.1.4.1781';
/**
* OID for Virtual List View (VLV) Request Control. Used to request a specific range of entries.
*
* @var string
*/
public const OID_SERVER_CONTROL_VLVREQUEST = '2.16.840.1.113730.3.4.9';
/**
* OID for the 'matchingRuleInChain' matching rule. Used for substring searches in multi-valued attributes.
*/
public const OID_MATCHING_RULE_IN_CHAIN = '1.2.840.113556.1.4.1941';
/**
* Set the current connection to use TLS (ldaps:// protocol).
*/
public function setTLS(bool $enabled = true): static;
/**
* Determine if the current connection instance is using TLS (ldaps:// protocol).
*/
public function isUsingTLS(): bool;
/**
* Set the current connection to use STARTTLS (ldap:// with upgrade).
*/
public function setStartTLS(bool $enabled = true): static;
/**
* Determine if the current connection instance is using STARTTLS (ldap:// with upgrade).
*/
public function isUsingStartTLS(): bool;
/**
* Determine if the connection is bound.
*/
public function isBound(): bool;
/**
* Determine if the connection is secure over TLS or SSL.
*/
public function isSecure(): bool;
/**
* Determine if the connection has been created.
*/
public function isConnected(): bool;
/**
* Determine the connection is able to modify passwords.
*/
public function canChangePasswords(): bool;
/**
* Get the full LDAP host URL.
*
* Ex: ldap://192.168.1.1:386
*/
public function getHost(): ?string;
/**
* Get the underlying raw LDAP connection.
*/
public function getConnection(): ?Connection;
/**
* Retrieve the entries from a search result.
*
* @see http://php.net/manual/en/function.ldap-get-entries.php
*
* @param Result $result
*/
public function getEntries(mixed $result): array;
/**
* Get the entry identifier for first entry in the result.
*
* @see https://www.php.net/manual/en/function.ldap-first-entry.php
*
* @param Result $result
*/
public function getFirstEntry(mixed $result): mixed;
/**
* Retrieve the next result entry.
*
* @see https://www.php.net/manual/en/function.ldap-next-entry.php
*
* @param Result $entry
*/
public function getNextEntry(mixed $entry): mixed;
/**
* Reads attributes and values from an entry in the search result.
*
* @see https://www.php.net/manual/en/function.ldap-get-attributes.php
*
* @param Result $entry
*/
public function getAttributes(mixed $entry): array|false;
/**
* Reads all the values of the attribute in the entry in the result.
*
* @param Result $entry
*/
public function getValuesLen(mixed $entry, string $attribute): array|false;
/**
* Retrieve the last error on the current connection.
*
* @see http://php.net/manual/en/function.ldap-error.php
*/
public function getLastError(): ?string;
/**
* Return detailed information about an error.
*
* Returns null when there was a successful last request.
*
* Returns DetailedError when there was an error.
*/
public function getDetailedError(): ?DetailedError;
/**
* Count the number of entries in a search.
*
* @see https://www.php.net/manual/en/function.ldap-count-entries.php
*
* @param Result $result
*/
public function countEntries(mixed $result): int;
/**
* Compare value of attribute found in entry specified with DN.
*/
public function compare(string $dn, string $attribute, string $value, ?array $controls = null): bool|int;
/**
* Set an option on the current connection.
*
* @see http://php.net/manual/en/function.ldap-set-option.php
*/
public function setOption(int $option, mixed $value): bool;
/**
* Set multiple options on the current connection.
*/
public function setOptions(array $options = []): void;
/**
* Set a callback function to do re-binds on referral chasing.
*
* @see https://www.php.net/manual/en/function.ldap-set-rebind-proc.php
*/
public function setRebindCallback(callable $callback): bool;
/**
* Get the value for the LDAP option.
*
* @see https://www.php.net/manual/en/function.ldap-get-option.php
*/
public function getOption(int $option, mixed &$value = null): mixed;
/**
* Starts a connection using TLS.
*
* @see http://php.net/manual/en/function.ldap-start-tls.php
*
* @throws LdapRecordException
*/
public function startTLS(): bool;
/**
* Connects to the specified hostname using the specified port.
*
* @see http://php.net/manual/en/function.ldap-start-tls.php
*/
public function connect(string|array $hosts = [], int $port = 389, ?string $protocol = null): bool;
/**
* Closes the current connection.
*
* Returns false if no connection is present.
*
* @see http://php.net/manual/en/function.ldap-close.php
*/
public function close(): bool;
/**
* Performs a search on the current connection.
*
* @see http://php.net/manual/en/function.ldap-search.php
*
* @return Result
*/
public function search(string $dn, string $filter, array $attributes, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed;
/**
* Performs a single level search on the current connection.
*
* @see http://php.net/manual/en/function.ldap-list.php
*
* @return Result
*/
public function list(string $dn, string $filter, array $attributes, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed;
/**
* Reads an entry on the current connection.
*
* @see http://php.net/manual/en/function.ldap-read.php
*
* @return Result
*/
public function read(string $dn, string $filter, array $attributes, bool $onlyAttributes = false, int $size = 0, int $time = 0, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): mixed;
/**
* Extract information from an LDAP result.
*
* @see https://www.php.net/manual/en/function.ldap-parse-result.php
*
* @param Result $result
*/
public function parseResult(mixed $result, int &$errorCode = 0, ?string &$dn = null, ?string &$errorMessage = null, ?array &$referrals = null, ?array &$controls = null): LdapResultResponse|false;
/**
* Bind to the LDAP directory.
*
* @see http://php.net/manual/en/function.ldap-bind.php
*
* @throws LdapRecordException
*/
public function bind(?string $dn = null, ?string $password = null, ?array $controls = null): LdapResultResponse;
/**
* Bind to the LDAP directory using SASL.
*
* SASL options:
* - mech: Mechanism (Defaults: null)
* - realm: Realm (Defaults: null)
* - authc_id: Verification Identity (Defaults: null)
* - authz_id: Authorization Identity (Defaults: null)
* - props: Options for Authorization Identity (Defaults: null)
*
* @see https://php.net/manual/en/function.ldap-sasl-bind.php
* @see https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml
*/
public function saslBind(?string $dn = null, ?string $password = null, array $options = []): bool;
/**
* Adds an entry to the current connection.
*
* @see http://php.net/manual/en/function.ldap-add.php
*
* @throws LdapRecordException
*/
public function add(string $dn, array $entry): bool;
/**
* Deletes an entry on the current connection.
*
* @see http://php.net/manual/en/function.ldap-delete.php
*
* @throws LdapRecordException
*/
public function delete(string $dn): bool;
/**
* Modify the name of an entry on the current connection.
*
* @see http://php.net/manual/en/function.ldap-rename.php
*
* @throws LdapRecordException
*/
public function rename(string $dn, string $newRdn, string $newParent, bool $deleteOldRdn = false): bool;
/**
* Modifies an existing entry on the current connection.
*
* @see http://php.net/manual/en/function.ldap-modify.php
*
* @throws LdapRecordException
*/
public function modify(string $dn, array $entry): bool;
/**
* Batch modifies an existing entry on the current connection.
*
* @see http://php.net/manual/en/function.ldap-modify-batch.php
*
* @throws LdapRecordException
*/
public function modifyBatch(string $dn, array $values): bool;
/**
* Add attribute values to current attributes.
*
* @see http://php.net/manual/en/function.ldap-mod-add.php
*
* @throws LdapRecordException
*/
public function modAdd(string $dn, array $entry): bool;
/**
* Replaces attribute values with new ones.
*
* @see http://php.net/manual/en/function.ldap-mod-replace.php
*
* @throws LdapRecordException
*/
public function modReplace(string $dn, array $entry): bool;
/**
* Delete attribute values from current attributes.
*
* @see http://php.net/manual/en/function.ldap-mod-del.php
*
* @throws LdapRecordException
*/
public function modDelete(string $dn, array $entry): bool;
/**
* Frees up the memory allocated internally to store the result.
*
* @see https://www.php.net/manual/en/function.ldap-free-result.php
*
* @param Result $result
*/
public function freeResult(mixed $result): bool;
/**
* Get the error number of the last command executed.
*
* @see http://php.net/manual/en/function.ldap-errno.php
*/
public function errNo(): ?int;
/**
* Get the error string of the specified error number.
*
* @see http://php.net/manual/en/function.ldap-err2str.php
*/
public function err2Str(int $number): string;
/**
* Get the LDAP protocol to utilize for the current connection.
*/
public function getProtocol(): string;
/**
* Get the extended error code of the last command.
*/
public function getExtendedError(): ?string;
/**
* Get the diagnostic message.
*/
public function getDiagnosticMessage(): ?string;
}