3 namespace Adldap\Connections
;
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
15 * The SSL LDAP protocol string.
19 const PROTOCOL_SSL
= 'ldaps://';
22 * The standard LDAP protocol string.
26 const PROTOCOL
= 'ldap://';
29 * The LDAP SSL port number.
36 * The standard LDAP port number.
43 * Returns true / false if the
44 * current connection is supported
45 * on the current PHP install.
49 public function isSupported();
52 * Returns true / false if the
53 * current connection supports
54 * SASL for single sign on
59 public function isSaslSupported();
62 * Returns true / false if the
63 * current connection pagination.
67 public function isPagingSupported();
70 * Returns true / false if the
71 * current connection supports batch
76 public function isBatchSupported();
79 * Returns true / false if the
80 * current connection instance is using
85 public function isUsingSSL();
88 * Returns true / false if the
89 * current connection instance is using
94 public function isUsingTLS();
97 * Returns true / false if the current
98 * connection is able to modify passwords.
102 public function canChangePasswords();
105 * Returns true / false if the current
106 * connection is bound.
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.
135 public function getConnection();
138 * Retrieve the entries from a search result.
140 * @param $searchResult
144 public function getEntries($searchResult);
147 * Returns the number of entries from a search
150 * @param $searchResult
154 public function countEntries($searchResult);
157 * Compare value of attribute found in entry specified with DN.
160 * @param string $attribute
161 * @param string $value
165 public function compare($dn, $attribute, $value);
168 * Retrieves the first entry from a search result.
170 * @param $searchResult
174 public function getFirstEntry($searchResult);
177 * Retrieves the next entry from a search result.
183 public function getNextEntry($entry);
186 * Retrieves the ldap entry's attributes.
192 public function getAttributes($entry);
195 * Retrieve the last error on the current
200 public function getLastError();
203 * Get all binary values from the specified result entry.
210 public function getValuesLen($entry, $attribute);
213 * Sets an option on the current connection.
216 * @param mixed $value
220 public function setOption($option, $value);
223 * Sets options on the current connection.
225 * @param array $options
229 public function setOptions(array $options = []);
232 * Set a callback function to do re-binds on referral chasing.
234 * @param callable $callback
238 public function setRebindCallback(callable
$callback);
241 * Connects to the specified hostname using the specified port.
243 * @param string|array $hostname
248 public function connect($hostname = [], $port = 389);
251 * Starts a connection using TLS.
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
263 * @param string $username
264 * @param string $password
269 public function bind($username, $password, $sasl = false);
272 * Closes the current connection.
274 * Returns false if no connection is present.
278 public function close();
281 * Performs a search on the current connection.
284 * @param string $filter
285 * @param array $fields
286 * @param bool $onlyAttributes
292 public function search($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0);
295 * Reads an entry on the current connection.
299 * @param array $fields
300 * @param bool $onlyAttributes
306 public function read($dn, $filter, array $fields, $onlyAttributes = false, $size = 0, $time = 0);
309 * Performs a single level search on the current connection.
312 * @param string $filter
313 * @param array $attributes
314 * @param bool $onlyAttributes
320 public function listing($dn, $filter, array $attributes, $onlyAttributes = false, $size = 0, $time = 0);
323 * Adds an entry to the current connection.
326 * @param array $entry
330 public function add($dn, array $entry);
333 * Deletes an entry on the current connection.
339 public function delete($dn);
342 * Modify the name of an entry on the current
346 * @param string $newRdn
347 * @param string $newParent
348 * @param bool $deleteOldRdn
352 public function rename($dn, $newRdn, $newParent, $deleteOldRdn = false);
355 * Modifies an existing entry on the
356 * current connection.
359 * @param array $entry
363 public function modify($dn, array $entry);
366 * Batch modifies an existing entry on the
367 * current connection.
370 * @param array $values
374 public function modifyBatch($dn, array $values);
377 * Add attribute values to current attributes.
380 * @param array $entry
384 public function modAdd($dn, array $entry);
387 * Replaces attribute values with new ones.
390 * @param array $entry
394 public function modReplace($dn, array $entry);
397 * Delete attribute values from current attributes.
400 * @param array $entry
404 public function modDelete($dn, array $entry);
407 * Send LDAP pagination control.
409 * @param int $pageSize
410 * @param bool $isCritical
411 * @param string $cookie
415 public function controlPagedResult($pageSize = 1000, $isCritical = false, $cookie = '');
418 * Retrieve a paginated result response.
421 * @param string $cookie
425 public function controlPagedResultResponse($result, &$cookie);
428 * Returns the error number of the last command
429 * executed on the current connection.
433 public function errNo();
436 * Returns the extended error string of the last command.
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.
454 public function getExtendedErrorCode();
457 * Returns the error string of the specified
464 public function err2Str($number);
467 * Return the diagnostic Message.
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);