composer package updates
[openemr.git] / vendor / adldap2 / adldap2 / src / Connections / ConnectionInterface.php
blob161079b893ea8a3d858a0170ab3b9eb5f047e83f
1 <?php
3 namespace Adldap\Connections;
5 /**
6 * The Connection interface used for making connections. Implementing
7 * this interface on connection classes helps unit and functional
8 * test classes that require a connection.
10 * Interface ConnectionInterface
12 interface ConnectionInterface
14 /**
15 * The SSL LDAP protocol string.
17 * @var string
19 const PROTOCOL_SSL = 'ldaps://';
21 /**
22 * The standard LDAP protocol string.
24 * @var string
26 const PROTOCOL = 'ldap://';
28 /**
29 * The LDAP SSL port number.
31 * @var string
33 const PORT_SSL = 636;
35 /**
36 * The standard LDAP port number.
38 * @var string
40 const PORT = 389;
42 /**
43 * Returns true / false if the
44 * current connection is supported
45 * on the current PHP install.
47 * @return bool
49 public function isSupported();
51 /**
52 * Returns true / false if the
53 * current connection supports
54 * SASL for single sign on
55 * capability.
57 * @return bool
59 public function isSaslSupported();
61 /**
62 * Returns true / false if the
63 * current connection pagination.
65 * @return bool
67 public function isPagingSupported();
69 /**
70 * Returns true / false if the
71 * current connection supports batch
72 * modification.
74 * @return bool
76 public function isBatchSupported();
78 /**
79 * Returns true / false if the
80 * current connection instance is using
81 * SSL.
83 * @return bool
85 public function isUsingSSL();
87 /**
88 * Returns true / false if the
89 * current connection instance is using
90 * TLS.
92 * @return bool
94 public function isUsingTLS();
96 /**
97 * Returns true / false if the current
98 * connection is able to modify passwords.
100 * @return bool
102 public function canChangePasswords();
105 * Returns true / false if the current
106 * connection is bound.
108 * @return bool
110 public function isBound();
113 * Sets the current connection to use SSL.
115 * @param bool $enabled
117 * @return ConnectionInterface
119 public function ssl($enabled = true);
122 * Sets the current connection to use TLS.
124 * @param bool $enabled
126 * @return ConnectionInterface
128 public function tls($enabled = true);
131 * Get the current connection.
133 * @return mixed
135 public function getConnection();
138 * Retrieve the entries from a search result.
140 * @param $searchResult
142 * @return mixed
144 public function getEntries($searchResult);
147 * Returns the number of entries from a search
148 * result.
150 * @param $searchResult
152 * @return int
154 public function countEntries($searchResult);
157 * Compare value of attribute found in entry specified with DN.
159 * @param string $dn
160 * @param string $attribute
161 * @param string $value
163 * @return mixed
165 public function compare($dn, $attribute, $value);
168 * Retrieves the first entry from a search result.
170 * @param $searchResult
172 * @return mixed
174 public function getFirstEntry($searchResult);
177 * Retrieves the next entry from a search result.
179 * @param $entry
181 * @return mixed
183 public function getNextEntry($entry);
186 * Retrieves the ldap entry's attributes.
188 * @param $entry
190 * @return mixed
192 public function getAttributes($entry);
195 * Retrieve the last error on the current
196 * connection.
198 * @return string
200 public function getLastError();
203 * Get all binary values from the specified result entry.
205 * @param $entry
206 * @param $attribute
208 * @return array
210 public function getValuesLen($entry, $attribute);
213 * Sets an option on the current connection.
215 * @param int $option
216 * @param mixed $value
218 * @return mixed
220 public function setOption($option, $value);
223 * Sets options on the current connection.
225 * @param array $options
227 * @return mixed
229 public function setOptions(array $options = []);
232 * Set a callback function to do re-binds on referral chasing.
234 * @param callable $callback
236 * @return bool
238 public function setRebindCallback(callable $callback);
241 * Connects to the specified hostname using the specified port.
243 * @param string|array $hostname
244 * @param int $port
246 * @return mixed
248 public function connect($hostname = [], $port = 389);
251 * Starts a connection using TLS.
253 * @return mixed
255 public function startTLS();
258 * Binds to the current connection using
259 * the specified username and password. If sasl
260 * is true, the current connection is bound using
261 * SASL.
263 * @param string $username
264 * @param string $password
265 * @param bool $sasl
267 * @return bool
269 public function bind($username, $password, $sasl = false);
272 * Closes the current connection.
274 * Returns false if no connection is present.
276 * @return bool
278 public function close();
281 * Performs a search on the current connection.
283 * @param string $dn
284 * @param string $filter
285 * @param array $fields
286 * @param bool $onlyAttributes
287 * @param int $size
288 * @param int $time
290 * @return mixed
292 public function search($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0);
295 * Reads an entry on the current connection.
297 * @param string $dn
298 * @param $filter
299 * @param array $fields
300 * @param bool $onlyAttributes
301 * @param int $size
302 * @param int $time
304 * @return mixed
306 public function read($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0);
309 * Performs a single level search on the current connection.
311 * @param string $dn
312 * @param string $filter
313 * @param array $attributes
314 * @param bool $onlyAttributes
315 * @param int $size
316 * @param int $time
318 * @return mixed
320 public function listing($dn, $filter, array $attributes, $onlyAttributes = false, $size = 0, $time = 0);
323 * Adds an entry to the current connection.
325 * @param string $dn
326 * @param array $entry
328 * @return bool
330 public function add($dn, array $entry);
333 * Deletes an entry on the current connection.
335 * @param string $dn
337 * @return bool
339 public function delete($dn);
342 * Modify the name of an entry on the current
343 * connection.
345 * @param string $dn
346 * @param string $newRdn
347 * @param string $newParent
348 * @param bool $deleteOldRdn
350 * @return bool
352 public function rename($dn, $newRdn, $newParent, $deleteOldRdn = false);
355 * Modifies an existing entry on the
356 * current connection.
358 * @param string $dn
359 * @param array $entry
361 * @return bool
363 public function modify($dn, array $entry);
366 * Batch modifies an existing entry on the
367 * current connection.
369 * @param string $dn
370 * @param array $values
372 * @return mixed
374 public function modifyBatch($dn, array $values);
377 * Add attribute values to current attributes.
379 * @param string $dn
380 * @param array $entry
382 * @return mixed
384 public function modAdd($dn, array $entry);
387 * Replaces attribute values with new ones.
389 * @param string $dn
390 * @param array $entry
392 * @return mixed
394 public function modReplace($dn, array $entry);
397 * Delete attribute values from current attributes.
399 * @param string $dn
400 * @param array $entry
402 * @return mixed
404 public function modDelete($dn, array $entry);
407 * Send LDAP pagination control.
409 * @param int $pageSize
410 * @param bool $isCritical
411 * @param string $cookie
413 * @return mixed
415 public function controlPagedResult($pageSize = 1000, $isCritical = false, $cookie = '');
418 * Retrieve a paginated result response.
420 * @param $result
421 * @param string $cookie
423 * @return mixed
425 public function controlPagedResultResponse($result, &$cookie);
428 * Returns the error number of the last command
429 * executed on the current connection.
431 * @return int
433 public function errNo();
436 * Returns the extended error string of the last command.
438 * @return string
440 public function getExtendedError();
443 * Returns the extended error hex code of the last command.
445 * @return string|null
447 public function getExtendedErrorHex();
450 * Returns the extended error code of the last command.
452 * @return string
454 public function getExtendedErrorCode();
457 * Returns the error string of the specified
458 * error number.
460 * @param int $number
462 * @return string
464 public function err2Str($number);
467 * Return the diagnostic Message.
469 * @return string
471 public function getDiagnosticMessage();
474 * Extract the diagnostic code from the message.
476 * @param string $message
478 * @return string|bool
480 public function extractDiagnosticCode($message);