37 var $reconnect = FALSE;
61 var $objectClasses = [];
67 var $follow_referral = FALSE;
71 var $max_ldap_query_time = 0;
86 function __construct ($binddn, $bindpw, $hostname, $follow_referral = FALSE, $tls = FALSE)
89 $this->follow_referral = $follow_referral;
91 $this->binddn = $binddn;
92 $this->bindpw = $bindpw;
93 $this->hostname = $hostname;
96 if (is_object($config) && ($config->get_cfg_value(
"ldapMaxQueryTime") !=
"")) {
97 $str = $config->get_cfg_value(
"ldapMaxQueryTime");
98 $this->max_ldap_query_time = (float)($str);
109 $this->hascon = FALSE;
127 public static function init (
string $server,
string $base,
string $binddn =
'',
string $pass =
''):
LDAP 131 $ldap =
new LDAP($binddn, $pass, $server,
132 isset($config->current[
'LDAPFOLLOWREFERRALS']) && $config->current[
'LDAPFOLLOWREFERRALS'] ==
'TRUE',
133 isset($config->current[
'LDAPTLS']) && $config->current[
'LDAPTLS'] ==
'TRUE');
136 if (!$ldap->success()) {
137 throw new FatalError(
htmlescape(sprintf(_(
'FATAL: Error when connecting to LDAP. Server said "%s".'), $ldap->get_error())));
152 $this->sr[$this->srp] = NULL;
153 $this->start[$this->srp] = 0;
154 $this->hasres[$this->srp] = FALSE;
165 trigger_error(
'deprecated, use ldap_escape_f instead');
166 return ldap_escape_f($dn);
176 return _(ldap_err2str(49));
186 $this->hascon = FALSE;
188 if ($this->cid = @ldap_connect($this->hostname)) {
189 @ldap_set_option($this->cid, LDAP_OPT_PROTOCOL_VERSION, 3);
190 if ($this->follow_referral) {
191 @ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
192 @ldap_set_rebind_proc($this->cid, [&$this,
'rebind']);
195 @ldap_start_tls($this->cid);
198 $this->error =
'No Error';
201 $serverctrls = [[
'oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]];
203 $result = @ldap_bind_ext($this->cid, $this->binddn, $this->bindpw, $serverctrls);
204 if (@ldap_parse_result($this->cid, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls)) {
205 if (isset($ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE][
'value'][
'error'])) {
206 $this->hascon = FALSE;
207 switch ($ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE][
'value'][
'error']) {
210 $this->error = _(
'It seems your user password has expired. Please use <a href="recovery.php">password recovery</a> to change it.');
214 $this->error = _(
'Account locked. Please contact your system administrator!');
218 $this->error =
'changeAfterReset';
233 $this->error = sprintf(_(
'Unexpected ppolicy error "%s", please contact the administrator'), $ctrls[LDAP_CONTROL_PASSWORDPOLICYRESPONSE][
'value'][
'error']);
238 $this->hascon = ($errcode == 0);
239 if ($errcode == 49) {
240 $this->error = static::invalidCredentialsError();
241 } elseif (empty($errmsg)) {
242 $this->error = ldap_err2str($errcode);
244 $this->error = $errmsg;
248 $this->error =
'Parsing of LDAP result from bind failed';
249 $this->hascon = FALSE;
252 $this->error =
'Could not connect to LDAP server';
263 $credentials = $this->get_credentials($referral);
264 if (@ldap_bind($ldap, $credentials[
'ADMINDN'], $credentials[
'ADMINPASSWORD'])) {
265 $this->error =
"Success";
266 $this->hascon = TRUE;
271 $this->error =
"Could not bind to " . $credentials[
'ADMINDN'];
292 @ldap_unbind($this->cid);
303 @ldap_close($this->cid);
304 $this->hascon = FALSE;
320 $this->basedn = $dir;
334 $basedn = $this->basedn;
336 return preg_replace(
"/[^,]*[,]*[ ]*(.*)/",
"$1", $basedn);
350 function search ($srp, $filter, $attrs = [], $scope =
'subtree', array $controls = NULL)
357 $startTime = microtime(TRUE);
359 switch (strtolower($scope)) {
361 if (isset($controls)) {
362 $this->sr[$srp] = @ldap_read($this->cid, $this->basedn, $filter, $attrs, 0, 0, 0, LDAP_DEREF_NEVER, $controls);
364 $this->sr[$srp] = @ldap_read($this->cid, $this->basedn, $filter, $attrs);
368 if (isset($controls)) {
369 $this->sr[$srp] = @ldap_list($this->cid, $this->basedn, $filter, $attrs, 0, 0, 0, LDAP_DEREF_NEVER, $controls);
371 $this->sr[$srp] = @ldap_list($this->cid, $this->basedn, $filter, $attrs);
376 if (isset($controls)) {
377 $this->sr[$srp] = @ldap_search($this->cid, $this->basedn, $filter, $attrs, 0, 0, 0, LDAP_DEREF_NEVER, $controls);
379 $this->sr[$srp] = @ldap_search($this->cid, $this->basedn, $filter, $attrs);
383 $this->error = @ldap_error($this->cid);
385 $this->hasres[$srp] = TRUE;
388 $diff = microtime(TRUE) - $startTime;
389 if ($this->max_ldap_query_time && ($diff > $this->max_ldap_query_time)) {
394 $this->
log(
"LDAP operation: time=".$diff.
" operation=search('".$this->basedn.
"', '$filter')");
395 logging::debug(
DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error,
'search(base="'.$this->basedn.
'",scope="'.$scope.
'",filter="'.$filter.
'")');
396 return $this->sr[$srp];
398 $this->error =
"Could not connect to LDAP server";
399 logging::debug(
DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error,
'search(base="'.$this->basedn.
'",scope="'.$scope.
'",filter="'.$filter.
'")');
412 if ($this->hascon && $this->hasres[$srp]) {
413 if (ldap_parse_result($this->cid, $this->sr[$srp], $errcode, $matcheddn, $errmsg, $referrals, $controls)) {
414 return [$errcode, $matcheddn, $errmsg, $referrals, $controls];
433 function ls ($srp, $filter =
"(objectclass=*)", $basedn =
"", $attrs = [
"*"])
435 trigger_error(
'deprecated');
437 return $this->
search($srp, $filter, $attrs,
'one');
451 function cat ($srp, $dn, $attrs = [
"*"], $filter =
"(objectclass=*)")
459 $this->sr[$srp] = @ldap_read($this->cid, $dn, $filter, $attrs);
460 $this->error = @ldap_error($this->cid);
462 $this->hasres[$srp] = TRUE;
463 logging::debug(
DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error,
'cat(dn="'.$dn.
'",filter="'.$filter.
'")');
464 return $this->sr[$srp];
466 $this->error =
"Could not connect to LDAP server";
467 logging::debug(
DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error,
'cat(dn="'.$dn.
'",filter="'.$filter.
'")');
485 $res = @ldap_read($this->cid, $dn, $filter, [
"objectClass"]);
486 logging::debug(
DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error,
'object_match_filter(dn="'.$dn.
'",filter="'.$filter.
'")');
487 return @ldap_count_entries($this->cid, $res);
489 $this->error =
"Could not connect to LDAP server";
490 logging::debug(
DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error,
'object_match_filter(dn="'.$dn.
'",filter="'.$filter.
'")');
504 @ldap_set_option($this->cid, LDAP_OPT_SIZELIMIT, 10000000);
507 @ldap_set_option($this->cid, LDAP_OPT_SIZELIMIT, $size);
509 $this->error =
"Could not connect to LDAP server";
520 function fetch ($srp,
bool $cleanUpNumericIndices = FALSE)
523 if ($this->hasres[$srp]) {
524 if ($this->start[$srp] == 0) {
525 if ($this->sr[$srp]) {
526 $this->start[$srp] = 1;
527 $this->re[$srp] = @ldap_first_entry($this->cid, $this->sr[$srp]);
532 $this->re[$srp] = @ldap_next_entry($this->cid, $this->re[$srp]);
535 if ($this->re[$srp]) {
536 $att = @ldap_get_attributes($this->cid, $this->re[$srp]);
537 $att[
'dn'] = trim(@ldap_get_dn($this->cid, $this->re[$srp]));
538 if ($cleanUpNumericIndices && isset($att[
'count'])) {
539 for ($i = 0; $i < $att[
'count']; ++$i) {
543 unset($att[
'count']);
546 $this->error = @ldap_error($this->cid);
550 $this->error =
"Perform a fetch with no search";
555 $this->error =
"Could not connect to LDAP server";
568 $this->start[$srp] = 0;
578 if ($this->hasres[$srp]) {
579 $this->hasres[$srp] = FALSE;
580 @ldap_free_result($this->sr[$srp]);
592 if ($this->hasres[$srp]) {
593 if (!$this->re[$srp]) {
594 $this->error =
"Perform a Fetch with no valid Result";
596 $rv = @ldap_get_dn($this->cid, $this->re[$srp]);
598 $this->error = @ldap_error($this->cid);
602 $this->error =
"Perform a Fetch with no Search";
606 $this->error =
"Could not connect to LDAP server";
619 if ($this->hasres[$srp]) {
620 $rv = @ldap_count_entries($this->cid, $this->sr[$srp]);
621 $this->error = @ldap_error($this->cid);
625 $this->error =
"Perform a Fetch with no Search";
630 $this->error =
"Could not connect to LDAP server";
644 function rm ($attrs =
"", $dn =
"")
654 $r = ldap_mod_del($this->cid, $dn, $attrs);
655 $this->error = @ldap_error($this->cid);
659 $this->error =
'Could not connect to LDAP server';
665 function mod_add ($attrs =
"", $dn =
"")
675 $r = @ldap_mod_add($this->cid, $dn, $attrs);
676 $this->error = @ldap_error($this->cid);
680 $this->error =
"Could not connect to LDAP server";
697 $r = @ldap_delete($this->cid, $deletedn);
698 $this->error = @ldap_error($this->cid);
700 return ($r ? $r : 0);
702 $this->error =
"Could not connect to LDAP server";
721 if (strtolower($source) == strtolower($dest)) {
722 trigger_error(
"Source and destination can't be the same entry.");
723 $this->error =
"Source and destination can't be the same entry.";
728 if ($this->dn_exists($dest)) {
729 trigger_error(
"Destination '$dest' already exists.");
730 $this->error =
"Destination '$dest' already exists.";
739 $parent = preg_replace(
"/^[^,]+,/",
"", $dest);
740 $dest_rdn = preg_replace(
"/,.*$/",
"", $dest);
747 $r = ldap_rename($this->cid, $source, $dest_rdn, $parent, TRUE);
748 $this->error = ldap_error($this->cid);
751 $r &= $this->dn_exists($dest);
755 $this->error =
"Could not connect to LDAP server";
782 $this->
cd($deletedn);
783 $this->
search($srp,
'(objectClass=*)', [
'dn']);
784 while ($attrs = $this->
fetch($srp)) {
785 $delarray[$attrs[
'dn']] = strlen($attrs[
'dn']);
792 foreach (array_keys($delarray) as $key) {
793 $r = @ldap_delete($this->cid, $key);
798 $this->error = @ldap_error($this->cid);
800 return ($r ? $r : 0);
802 $this->error =
"Could not connect to LDAP server";
808 function makeReadableErrors ($error, $attrs)
815 if (isset($attrs[
'objectClass'])
816 && preg_match(
"/^objectClass: value #([0-9]*) invalid per syntax$/", $this->
get_additional_error(), $m)) {
817 $ocs = $attrs[
'objectClass'];
818 if (!is_array($ocs)) {
821 if (isset($ocs[$m[1]])) {
822 $str .=
" - <b>objectClass: ".$ocs[$m[1]].
"</b>";
825 if ($error ==
"Undefined attribute type") {
841 if (
count($attrs) == 0) {
848 $r = @ldap_modify($this->cid, $this->basedn, $attrs);
849 $this->error = @ldap_error($this->cid);
851 $this->error .= $this->makeReadableErrors($this->error, $attrs);
854 return ($r ? $r : 0);
856 $this->error =
"Could not connect to LDAP server";
869 if (
count($changes) == 0) {
876 $r = @ldap_modify_batch($this->cid, $this->basedn, $changes);
877 $this->error = @ldap_error($this->cid);
881 $this->error =
'Could not connect to LDAP server';
898 $r = @ldap_add($this->cid, $this->basedn, $attrs);
899 $this->error = @ldap_error($this->cid);
901 $this->error .= $this->makeReadableErrors($this->error, $attrs);
904 return ($r ? $r : 0);
906 $this->error =
"Could not connect to LDAP server";
917 function create_missing_trees ($srp, $target, $ignoreReferralBases = TRUE)
919 $real_path = substr($target, 0, strlen($target) - strlen($this->basedn) - 1);
921 if ($target == $this->basedn) {
924 $l = array_reverse(ldap_explode_dn($real_path, 0));
927 $cdn = $this->basedn;
932 foreach ($l as $part) {
933 if ($part !=
"dummy") {
938 if ($ignoreReferralBases) {
940 foreach ($this->referrals as $ref) {
941 if ($ref[
'BASE'] == $cdn) {
952 if (!$this->dn_exists($cdn)) {
953 $type = preg_replace(
'/^([^=]+)=.*$/',
'\\1', $cdn);
954 $param = preg_replace(
'/^[^=]+=([^,]+).*$/',
'\\1', $cdn);
955 $param = preg_replace([
'/\\\\,/',
'/\\\\"/'], [
',',
'"'], $param);
960 if (
count($classes)) {
963 $ocname =
'locality';
967 foreach ($classes as $class) {
968 if (isset($class[
'MUST']) && in_array($type, $class[
'MUST'])) {
970 if (isset($class[
'STRUCTURAL'])) {
971 $ocname = $class[
'NAME'];
976 if (isset($class[
'AUXILIARY'])) {
977 $ocname = $class[
'NAME'];
989 $na[
'objectClass'] = [$ocname];
990 if (isset($classes[$ocname][
'AUXILIARY'])) {
991 $na[
'objectClass'][] = $classes[$ocname][
'SUP'];
995 $na[
'objectClass'][] =
'organization';
1003 if (isset($classes[$oc][
'MUST']) && is_array($classes[$oc][
'MUST'])) {
1004 foreach ($classes[$oc][
'MUST'] as $attr) {
1005 if (isset($na[$attr]) && !empty($na[$attr])) {
1008 $na[$attr] =
'filled';
1011 $oc = ($classes[$oc][
'SUP'] ?? NULL);
1017 $na[
'objectClass'] =
'organizationalUnit';
1021 $na[
'objectClass'] = [
'dcObject',
'top',
'organization'];
1051 $additional_error =
'';
1052 @ldap_get_option($this->cid, LDAP_OPT_ERROR_STRING, $additional_error);
1053 return $additional_error;
1063 return (trim($this->error) ===
'Success');
1071 if (($this->error ==
'Success') || !$details) {
1072 return $this->error;
1075 if ($adderror !=
'') {
1077 _(
'%s (%s, while operating on "%s" using LDAP server "%s")'),
1078 $this->error, $adderror, $this->basedn, $this->hostname
1082 _(
'%s (while operating on LDAP server "%s")'),
1083 $this->error, $this->hostname
1096 if ($this->error ==
'Success') {
1099 return @ldap_errno($this->cid) ?? -1;
1114 function get_credentials ($url, $referrals = NULL)
1117 $url = preg_replace(
'!\?\?.*$!',
'', $url);
1118 $server = preg_replace(
'!^([^:]+://[^/]+)/.*$!',
'\\1', $url);
1120 if ($referrals === NULL) {
1121 $referrals = $this->referrals;
1124 if (isset($referrals[$server])) {
1125 return $referrals[$server];
1127 $ret[
'ADMINDN'] = $this->binddn;
1128 $ret[
'ADMINPASSWORD'] = $this->bindpw;
1148 function generateLdif (
string $dn,
string $filter =
'(objectClass=*)',
string $scope =
'sub',
int $limit = 0,
int $wrap = NULL): string
1150 $limit = (($limit == 0) ?
'' :
' -z '.$limit);
1151 if ($wrap === NULL) {
1154 $wrap =
' -o ldif-wrap='.($wrap ? $wrap :
'no');
1158 $scope = trim($scope);
1159 if (!empty($scope) && !in_array($scope, [
'base',
'one',
'sub',
'children'])) {
1160 throw new LDIFExportException(sprintf(
'Invalid parameter for scope "%s", please use "base", "one", "sub" or "children".', $scope));
1162 $scope = (empty($scope) ?
'' :
' -s '.$scope);
1165 $dn = escapeshellarg($dn);
1166 $pwd = escapeshellarg($this->bindpw);
1167 $host = escapeshellarg($this->hostname);
1168 $admin = escapeshellarg($this->binddn);
1169 $filter = escapeshellarg($filter);
1171 $cmd =
'ldapsearch'.($this->tls ?
' -ZZ' :
'').
" -x -LLLL -D {$admin} {$filter} {$limit} {$wrap} {$scope} -H {$host} -b {$dn} -w {$pwd} ";
1181 $process = proc_open($cmd, $descriptorspec, $pipes);
1182 if ($process !== FALSE) {
1187 $res = stream_get_contents($pipes[1]);
1188 $err = stream_get_contents($pipes[2]);
1192 if (proc_close($process) != 0) {
1201 function dn_exists ($dn):
bool 1204 return (@ldap_read($this->cid, $dn,
'(objectClass=*)', [
'objectClass']) !== FALSE);
1207 function parseLdif (
string $str_attr): array
1210 $fileLines = preg_split(
"/\n/", $str_attr);
1211 if (end($fileLines) !=
'') {
1220 foreach ($fileLines as $lineNumber => $fileLine) {
1221 if (preg_match(
'/^ /', $fileLine)) {
1222 if ($line === NULL) {
1223 throw new LDIFImportException(sprintf(_(
'Error line %s, first line of an entry cannot start with a space'), $lineNumber));
1226 $line .= substr($fileLine, 1);
1228 if ($line !== NULL) {
1229 if (preg_match(
'/^#/', $line)
1230 || (preg_match(
'/^version:/', $line) && empty($entry))) {
1235 list ($key, $value) = explode(
':', $line, 2);
1236 $value = trim($value);
1237 if (preg_match(
'/^:/', $value)) {
1238 $value = base64_decode(trim(substr($value, 1)));
1240 if (preg_match(
'/^</', $value)) {
1241 throw new LDIFImportException(sprintf(_(
'Error line %s, references to an external file are not supported'), $lineNumber));
1243 if ($value ===
'') {
1244 throw new LDIFImportException(sprintf(_(
'Error line %s, attribute "%s" has no value'), $lineNumber, $key));
1247 if (!empty($entry)) {
1248 throw new LDIFImportException(sprintf(_(
'Error line %s, an entry bloc can only have one dn'), $lineNumber));
1250 $entry[
'dn'] = $value;
1251 $entryStart = $lineNumber;
1252 } elseif (empty($entry)) {
1253 throw new LDIFImportException(sprintf(_(
'Error line %s, an entry bloc should start with the dn'), $lineNumber));
1255 if (!isset($entry[$key])) {
1258 $entry[$key][] = $value;
1263 $line = trim($fileLine);
1265 if (!empty($entry)) {
1267 $entries[$entryStart] = $entry;
1297 $entries = $this->parseLdif($str_attr);
1303 foreach ($entries as $startLine => $entry) {
1305 $usermdir = ($this->dn_exists($entry[
'dn']) && $DeleteOldEntries);
1307 $usemodify = ($this->dn_exists($entry[
'dn']) && $JustModify);
1311 throw new LDIFImportException(sprintf(_(
'Error while importing dn: "%s", please check your LDIF from line %s on!'), $entry[
'dn'][0], $startLine));
1315 return count($entries);
1337 trigger_error(
"Can't import ldif, can't read config object.");
1349 if (isset($data[
'dn'])) {
1351 $tmp = ldap_explode_dn($data[
'dn'], 0);
1352 unset($tmp[
'count']);
1354 foreach ($tmp as $tm) {
1355 $dn .= trim($tm).
',';
1357 $dn = preg_replace(
'/,$/',
'', $dn);
1369 $this->
cd($config->current[
'BASE']);
1371 $this->create_missing_trees($srp, preg_replace(
'/^[^,]+,/',
'', $dn));
1377 $operation = LDAP_MOD;
1379 $this->cat($srp, $dn);
1380 if ($this->
count($srp)) {
1382 $attrs = $this->
fetch($srp);
1383 foreach (array_keys($attrs) as $name) {
1384 if (!is_numeric($name)) {
1385 if (in_array($name, [
'dn',
'count'])) {
1388 if (!isset($data[$name])) {
1393 $ret = $this->
modify($data);
1396 $operation = LDAP_ADD;
1397 $ret = $this->
add($data);
1401 $ret = $this->
modify($data);
1427 $res = @ldap_read($this->cid,
'',
'objectClass=*', [
'subschemaSubentry']);
1428 $attrs = @ldap_get_entries($this->cid, $res);
1429 if (!isset($attrs[0][
'subschemasubentry'][0])) {
1434 $nb = $attrs[0][
'subschemasubentry'][0];
1435 $objectclasses = [];
1436 $res = ldap_read($this->cid, $nb,
'objectClass=*', [
'objectclasses']);
1437 $attrs = ldap_get_entries($this->cid, $res);
1438 if (!isset($attrs[0])) {
1441 foreach ($attrs[0][
'objectclasses'] as $val) {
1442 if (preg_match(
'/^[0-9]+$/', $val)) {
1446 $pattern = explode(
' ', $val);
1447 $ocname = preg_replace(
"/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/",
'\\1', $val);
1448 $objectclasses[$ocname] = [];
1451 foreach ($pattern as $chunk) {
1460 $v = $this->value2container($value);
1461 if (in_array($name, [
'MUST',
'MAY']) && !is_array($v)) {
1464 $objectclasses[$ocname][$name] = $v;
1479 $v = $this->value2container($value);
1480 if (in_array($name, [
'MUST',
'MAY']) && !is_array($v)) {
1483 $objectclasses[$ocname][$name] = $v;
1489 default: $value .= $chunk.
' ';
1494 session::set(
'LDAP_CACHE::get_objectclasses', $objectclasses);
1497 return $objectclasses;
1501 function value2container ($value)
1504 if (preg_match(
'/^\s*$/', $value)) {
1509 $value = preg_replace(
'/^[\'"]/',
'', $value);
1510 $value = preg_replace(
'/[\'"] *$/',
'', $value);
1513 if (preg_match(
'/\$/', $value)) {
1514 $container = preg_split(
'/\s*\$\s*/', $value);
1516 $container = chop($value);
1531 if (isset($cfg->current[
'LDAPSTATS']) && preg_match(
'/true/i', $cfg->current[
'LDAPSTATS'])) {
1532 syslog(LOG_INFO, $string);
1546 $simple = explode(
",", $dn);
1548 foreach ($simple as $piece) {
1549 $partial = explode(
"=", $piece);
1551 if ($partial[0] ==
"cn") {
1557 public static function get_naming_contexts ($server, $admin =
'', $password =
'')
1560 $ds = ldap_connect($server);
1562 die(
'Can\'t bind to LDAP. No check possible!');
1564 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
1565 ldap_bind($ds, $admin, $password);
1568 $res = @ldap_read($ds,
'',
'objectClass=*', [
'namingContexts']);
1569 $attrs = @ldap_get_entries($ds, $res);
1572 return $attrs[0][
'namingcontexts'];
rename_dn($source, $dest)
Move the given Ldap entry from $source to $dest.
htmlescape(string $str)
Escape string for HTML output.
set_size_limit($size)
Set a size limit.
get_error($details=TRUE)
Get the error.
parse_result($srp)
Parse last result.
object_match_filter($dn, $filter)
Search object from a filter.
clearResult($srp)
Clear a result.
static get($name)
Accessor of a session var.
getSearchResource()
Get the search ressource.
cd($dir)
Change directory.
static prepare4filter($dn)
Function to fix problematic characters in DN's that are used for search requests. I...
rm($attrs="", $dn="")
Remove.
rmdir_recursive($srp, $deletedn)
Function rmdir_recursive.
get_errno()
Get the errno.
static set($name, $value)
Set a value in a session.
Error returned by an LDAP operation called from FusionDirectory.
log($string)
Add a string in log file.
rebind($ldap, $referral)
Rebind.
disconnect()
Disconnect to LDAP server.
connect()
Create a connection to LDAP server.
__construct($binddn, $bindpw, $hostname, $follow_referral=FALSE, $tls=FALSE)
Create a LDAP connection.
static invalidCredentialsError()
Error text that must be returned for invalid user or password.
fetch($srp, bool $cleanUpNumericIndices=FALSE)
Fetch.
getDN($srp)
Accessor of the DN.
import_single_entry($srp, $data, $modify, $delete)
Function to Imports a single entry.
__wakeup()
Remove bogus resources after unserialize.
static debug(int $level, int $line, string $function, string $file, $data, string $info='')
Debug output method.
getParentDir($basedn='')
Accessor of the parent directory of the basedn.
Parent class for all exceptions thrown in FusionDirectory.
This class contains all ldap function needed to make ldap operations easy.
hitSizeLimit()
Check if the search hit the size limit.
Fatal error class. Does not extend FusionDirectoryError.
Exception class which can be thrown by LDAP class if LDIF export fails.
get_objectclasses($force_reload=FALSE)
Get the object classes.
generateLdif(string $dn, string $filter='(objectClass=*)', string $scope='sub', int $limit=0, int $wrap=NULL)
Generates an ldif for all entries matching the filter settings, scope and limit.
modify(array $attrs)
Modify a entry of the directory LDAP.
static init(string $server, string $base, string $binddn='', string $pass='')
Initialize a LDAP connection.
count($srp)
Return the numbers of entries.
import_complete_ldif($srp, $str_attr, $JustModify, $DeleteOldEntries)
Function to imports ldifs.
add($attrs)
Add entry in the LDAP directory.
search($srp, $filter, $attrs=[], $scope='subtree', array $controls=NULL)
Search about filter.
resetResult($srp)
Reset the result.
Parent class for all errors in FusionDirectory.
unbind()
Unbind to LDAP server.
modify_batch(array $changes)
Modify a entry of the directory LDAP with fine control.
rmdir($deletedn)
Remove directory.
get_additional_error()
Get the LDAP additional error.
getCn($dn)
Function to get cn.
static is_set($name)
Check if the name of the session is set.
reconnect()
Reconnect to LDAP server.
Exception class which can be thrown by LDAP if the LDIF format is broken.
class_available($name)
Checks if a class is available.