46 public $errors = array();
51 public $server = array();
56 public $connectedServer;
77 public $ldapProtocolVersion;
103 public $searchPassword;
118 public $ldapErrorCode;
123 public $ldapErrorText;
138 public $filtermember;
148 public $attr_sambalogin;
158 public $attr_firstname;
239 public $ldapcharset =
'UTF-8';
254 const SYNCHRO_NONE = 0;
259 const SYNCHRO_DOLIBARR_TO_LDAP = 1;
264 const SYNCHRO_LDAP_TO_DOLIBARR = 2;
317 global $dolibarr_main_auth_ldap_debug;
322 $this->connectedServer =
'';
324 $ldapdebug = ((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug ==
"false") ?
false :
true);
328 print
"DEBUG: connectBind<br>\n";
332 if (count($this->server) == 0 || empty($this->server[0])) {
333 $this->error =
'LDAP setup (file conf.php) is not complete';
334 dol_syslog(get_class($this).
"::connectBind ".$this->error, LOG_WARNING);
338 if (!function_exists(
"ldap_connect")) {
339 $this->error =
'LDAPFunctionsNotAvailableOnPHP';
340 dol_syslog(get_class($this).
"::connectBind ".$this->error, LOG_WARNING);
344 if (empty($this->error)) {
346 foreach ($this->server as $host) {
354 if ($this->
serverPing($host, $this->serverPort)) {
356 dol_syslog(get_class($this).
"::connectBind serverPing true, we try ldap_connect to ".$host, LOG_DEBUG);
358 $this->connection = ldap_connect($host, $this->serverPort);
360 if (preg_match(
'/^ldaps/i', $host)) {
364 dol_syslog(get_class($this).
"::connectBind serverPing false, we try ldap_connect to ".$host, LOG_DEBUG);
366 $this->connection = ldap_connect($host, $this->serverPort);
369 dol_syslog(get_class($this).
"::connectBind serverPing false, no ldap_connect ".$host, LOG_DEBUG);
375 if (is_resource($this->connection) || is_object($this->connection)) {
377 dol_syslog(get_class($this).
"::connectBind this->connection is ok", LOG_DEBUG);
387 $resulttls = ldap_start_tls($this->connection);
389 dol_syslog(get_class($this).
"::connectBind failed to start tls", LOG_WARNING);
390 $this->error =
'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).
' '.ldap_error($this->connection);
400 if ($this->serverType ==
"activedirectory") {
402 dol_syslog(get_class($this).
"::connectBind try bindauth for activedirectory on ".$host.
" user=".$this->searchUser.
" password=".preg_replace(
'/./',
'*', $this->searchPassword), LOG_DEBUG);
403 $this->result = $this->
bindauth($this->searchUser, $this->searchPassword);
405 $this->
bind = $this->result;
407 $this->connectedServer = $host;
410 $this->error = ldap_errno($this->connection).
' '.ldap_error($this->connection);
414 if ($this->searchUser && $this->searchPassword) {
415 dol_syslog(get_class($this).
"::connectBind try bindauth on ".$host.
" user=".$this->searchUser.
" password=".preg_replace(
'/./',
'*', $this->searchPassword), LOG_DEBUG);
416 $this->result = $this->
bindauth($this->searchUser, $this->searchPassword);
418 $this->
bind = $this->result;
420 $this->connectedServer = $host;
423 $this->error = ldap_errno($this->connection).
' '.ldap_error($this->connection);
428 dol_syslog(get_class($this).
"::connectBind try bind anonymously on ".$host, LOG_DEBUG);
429 $result = $this->
bind();
431 $this->
bind = $this->result;
433 $this->connectedServer = $host;
436 $this->error = ldap_errno($this->connection).
' '.ldap_error($this->connection);
449 dol_syslog(get_class($this).
"::connectBind ".$connected, LOG_DEBUG);
452 $this->error =
'Failed to connect to LDAP'.($this->error ?
': '.$this->error :
'');
453 dol_syslog(get_class($this).
"::connectBind ".$this->error, LOG_WARNING);
479 if (!$this->result = @ldap_bind($this->connection)) {
480 $this->ldapErrorCode = ldap_errno($this->connection);
481 $this->ldapErrorText = ldap_error($this->connection);
482 $this->error = $this->ldapErrorCode.
" ".$this->ldapErrorText;
501 if (!$this->result = @ldap_bind($this->connection, $bindDn, $pass)) {
502 $this->ldapErrorCode = ldap_errno($this->connection);
503 $this->ldapErrorText = ldap_error($this->connection);
504 $this->error = $this->ldapErrorCode.
" ".$this->ldapErrorText;
519 $this->result =
true;
520 if (is_resource($this->connection) || is_object($this->connection)) {
521 $this->result = @ldap_unbind($this->connection);
538 @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version);
550 return ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion);
560 return ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0);
571 return ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
584 public function add($dn, $info, $user)
586 dol_syslog(get_class($this).
"::add dn=".$dn.
" info=".print_r($info,
true));
589 if (!$this->connection) {
590 $this->error =
"NotConnected";
594 $this->error =
"NotConnected";
600 foreach ($info as $key => $val) {
601 if (!is_array($val)) {
606 $this->
dump($dn, $info);
609 $result = @ldap_add($this->connection, $dn, $info);
612 dol_syslog(get_class($this).
"::add successful", LOG_DEBUG);
615 $this->ldapErrorCode = @ldap_errno($this->connection);
616 $this->ldapErrorText = @ldap_error($this->connection);
617 $this->error = $this->ldapErrorCode.
" ".$this->ldapErrorText;
618 dol_syslog(get_class($this).
"::add failed: ".$this->error, LOG_ERR);
632 public function modify($dn, $info, $user)
634 dol_syslog(get_class($this).
"::modify dn=".$dn.
" info=".print_r($info,
true));
637 if (!$this->connection) {
638 $this->error =
"NotConnected";
642 $this->error =
"NotConnected";
648 foreach ($info as $key => $val) {
649 if (!is_array($val)) {
654 $this->
dump($dn, $info);
659 if ($this->serverType ==
"activedirectory") {
663 if (isset($info[
'unicodePwd'])) {
664 $info[
'unicodePwd'] = mb_convert_encoding(
"\"".$info[
'unicodePwd'].
"\"",
"UTF-16LE",
"UTF-8");
667 $result = @ldap_mod_replace($this->connection, $dn, $info);
670 dol_syslog(get_class($this).
"::modify successful", LOG_DEBUG);
673 $this->error = @ldap_error($this->connection);
674 dol_syslog(get_class($this).
"::modify failed: ".$this->error, LOG_ERR);
690 public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn =
true)
692 dol_syslog(get_class($this).
"::modify dn=".$dn.
" newrdn=".$newrdn.
" newparent=".$newparent.
" deleteoldrdn=".($deleteoldrdn ? 1 : 0));
695 if (!$this->connection) {
696 $this->error =
"NotConnected";
700 $this->error =
"NotConnected";
710 $result = @ldap_rename($this->connection, $dn, $newrdn, $newparent, $deleteoldrdn);
713 dol_syslog(get_class($this).
"::rename successful", LOG_DEBUG);
716 $this->error = @ldap_error($this->connection);
717 dol_syslog(get_class($this).
"::rename failed: ".$this->error, LOG_ERR);
734 public function update($dn, $info, $user, $olddn, $newrdn =
'', $newparent =
'')
736 dol_syslog(get_class($this).
"::update dn=".$dn.
" olddn=".$olddn);
739 if (!$this->connection) {
740 $this->error =
"NotConnected";
744 $this->error =
"NotConnected";
748 if (!$olddn || $olddn != $dn) {
749 if (!empty($olddn) && !empty($newrdn) && !empty($newparent) && $this->ldapProtocolVersion ===
'3') {
751 $result = $this->
rename($olddn, $newrdn, $newparent, $user,
true);
752 $result = $this->
modify($dn, $info, $user);
755 $result = $this->
add($dn, $info, $user);
756 if ($result > 0 && $olddn && $olddn != $dn) {
757 $result = $this->
delete($olddn);
762 $result = $this->
add($dn, $info, $user);
763 $result = $this->
modify($dn, $info, $user);
766 $this->error = ldap_error($this->connection).
' (Code '.ldap_errno($this->connection).
") ".$this->error;
767 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
771 dol_syslog(get_class($this).
"::update done successfully");
784 public function delete($dn)
786 dol_syslog(get_class($this).
"::delete Delete LDAP entry dn=".$dn);
789 if (!$this->connection) {
790 $this->error =
"NotConnected";
794 $this->error =
"NotConnected";
801 $result = @ldap_delete($this->connection, $dn);
822 if (preg_match(
'/^ldap/', $this->server[0])) {
823 $target =
"-H ".implode(
',', $this->server);
825 $target =
"-h ".implode(
',', $this->server).
" -p ".$this->serverPort;
827 $content .=
"# ldapadd $target -c -v -D ".$this->searchUser.
" -W -f ldapinput.in\n";
828 $content .=
"# ldapmodify $target -c -v -D ".$this->searchUser.
" -W -f ldapinput.in\n";
829 $content .=
"# ldapdelete $target -c -v -D ".$this->searchUser.
" -W -f ldapinput.in\n";
830 if (in_array(
'localhost', $this->server)) {
831 $content .=
"# If commands fails to connect, try without -h and -p\n";
833 $content .=
"dn: ".$dn.
"\n";
834 foreach ($info as $key => $value) {
835 if (!is_array($value)) {
836 $content .=
"$key: $value\n";
838 foreach ($value as $valuevalue) {
839 $content .=
"$key: $valuevalue\n";
853 public function dump($dn, $info)
856 $ldapDirTemp = $conf->ldap->dir_temp;
863 $outputfile = $ldapDirTemp.
'/ldapinput.in';
864 $fp = fopen($outputfile,
"w");
866 fwrite($fp, $content);
889 if (preg_match(
'/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs)) {
891 $host =
'ssl://'.$regs[1];
892 } elseif (preg_match(
'/^ldap:\/\/([^\/]+)\/?$/', $host, $regs)) {
901 $errno = $errstr = 0;
910 $op = @fsockopen($host, $port, $errno, $errstr, $timeout);
935 dol_syslog(get_class($this).
"::addAttribute dn=".$dn.
" info=".implode(
',', $info));
938 if (!$this->connection) {
939 $this->error =
"NotConnected";
943 $this->error =
"NotConnected";
949 foreach ($info as $key => $val) {
950 if (!is_array($val)) {
955 $this->
dump($dn, $info);
958 $result = @ldap_mod_add($this->connection, $dn, $info);
961 dol_syslog(get_class($this).
"::add_attribute successful", LOG_DEBUG);
964 $this->error = @ldap_error($this->connection);
965 dol_syslog(get_class($this).
"::add_attribute failed: ".$this->error, LOG_ERR);
981 dol_syslog(get_class($this).
"::updateAttribute dn=".$dn.
" info=".implode(
',', $info));
984 if (!$this->connection) {
985 $this->error =
"NotConnected";
989 $this->error =
"NotConnected";
995 foreach ($info as $key => $val) {
996 if (!is_array($val)) {
1001 $this->
dump($dn, $info);
1004 $result = @ldap_mod_replace($this->connection, $dn, $info);
1007 dol_syslog(get_class($this).
"::updateAttribute successful", LOG_DEBUG);
1010 $this->error = @ldap_error($this->connection);
1011 dol_syslog(get_class($this).
"::updateAttribute failed: ".$this->error, LOG_ERR);
1027 dol_syslog(get_class($this).
"::deleteAttribute dn=".$dn.
" info=".implode(
',', $info));
1030 if (!$this->connection) {
1031 $this->error =
"NotConnected";
1035 $this->error =
"NotConnected";
1041 foreach ($info as $key => $val) {
1042 if (!is_array($val)) {
1047 $this->
dump($dn, $info);
1050 $result = @ldap_mod_del($this->connection, $dn, $info);
1053 dol_syslog(get_class($this).
"::deleteAttribute successful", LOG_DEBUG);
1056 $this->error = @ldap_error($this->connection);
1057 dol_syslog(get_class($this).
"::deleteAttribute failed: ".$this->error, LOG_ERR);
1072 if (!$this->connection) {
1073 $this->error =
"NotConnected";
1077 $this->error =
"NotConnected";
1081 $search = @ldap_search($this->connection, $dn, $filter);
1084 $entry = @ldap_first_entry($this->connection, $search);
1087 $this->ldapErrorCode = -1;
1088 $this->ldapErrorText =
"Couldn't find entry";
1093 if (!($values = ldap_get_attributes($this->connection, $entry))) {
1094 $this->ldapErrorCode = ldap_errno($this->connection);
1095 $this->ldapErrorText = ldap_error($this->connection);
1112 $attributes = array();
1113 $attributes[0] = $attribute;
1116 $this->result = @ldap_search($this->connection, $this->people, $filterrecord, $attributes);
1122 $entry = ldap_first_entry($this->connection, $this->result);
1125 $this->ldapErrorCode = -1;
1126 $this->ldapErrorText =
"Couldn't find user";
1131 if (!$values = @ldap_get_values_len($this->connection, $entry, $attribute)) {
1132 $this->ldapErrorCode = ldap_errno($this->connection);
1133 $this->ldapErrorText = ldap_error($this->connection);
1153 public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array())
1155 $fulllist = array();
1157 dol_syslog(get_class($this).
"::getRecords search=".$search.
" userDn=".$userDn.
" useridentifier=".$useridentifier.
" attributeArray=array(".implode(
',', $attributeArray).
") activefilter=".$activefilter);
1160 if ($this->serverType ==
"activedirectory") {
1161 $this->
bindauth($this->searchUser, $this->searchPassword);
1162 dol_syslog(get_class($this).
"::bindauth serverType=activedirectory searchUser=".$this->searchUser);
1166 if (!empty($activefilter)) {
1167 if (((
string) $activefilter ==
'1' || (
string) $activefilter ==
'user') && $this->filter) {
1168 $filter =
'('.$this->filter.
')';
1169 } elseif (((
string) $activefilter ==
'group') && $this->filtergroup) {
1170 $filter =
'('.$this->filtergroup.
')';
1171 } elseif (((
string) $activefilter ==
'member') && $this->filter) {
1172 $filter =
'('.$this->filtermember.
')';
1175 $filter =
'('.ldap_escape($useridentifier,
'', LDAP_ESCAPE_FILTER).
'=*)';
1178 $filter =
'('.ldap_escape($useridentifier,
'', LDAP_ESCAPE_FILTER).
'='.ldap_escape($search,
'', LDAP_ESCAPE_FILTER).
')';
1181 if (is_array($attributeArray)) {
1183 $attributeArray = array_values($attributeArray);
1184 dol_syslog(get_class($this).
"::getRecords connection=".$this->connectedServer.
":".$this->serverPort.
" userDn=".$userDn.
" filter=".$filter.
" attributeArray=(".implode(
',', $attributeArray).
")");
1186 $this->result = @ldap_search($this->connection, $userDn, $filter, $attributeArray);
1189 dol_syslog(get_class($this).
"::getRecords connection=".$this->connectedServer.
":".$this->serverPort.
" userDn=".$userDn.
" filter=".$filter);
1190 $this->result = @ldap_search($this->connection, $userDn, $filter);
1192 if (!$this->result) {
1193 $this->error =
'LDAP search failed: '.ldap_errno($this->connection).
" ".ldap_error($this->connection);
1197 $info = @ldap_get_entries($this->connection, $this->result);
1203 for ($i = 0; $i < $info[
"count"]; $i++) {
1204 $recordid = $this->
convToOutputCharset($info[$i][strtolower($useridentifier)][0], $this->ldapcharset);
1207 $fulllist[$recordid][$useridentifier] = $recordid;
1210 $num = count($attributeArray);
1211 for ($j = 0; $j < $num; $j++) {
1212 $keyattributelower = strtolower($attributeArray[$j]);
1216 if ($this->serverType ==
"activedirectory" && $keyattributelower ==
"objectsid") {
1218 $fulllist[$recordid][$attributeArray[$j]] = $objectsid;
1220 if (in_array($attributeArray[$j], $attributeAsArray) && is_array($info[$i][$keyattributelower])) {
1221 $valueTab = array();
1222 foreach ($info[$i][$keyattributelower] as $key => $value) {
1225 $fulllist[$recordid][$attributeArray[$j]] = $valueTab;
1227 $fulllist[$recordid][$attributeArray[$j]] = $this->
convToOutputCharset($info[$i][$keyattributelower][0], $this->ldapcharset);
1248 for ($x =
dol_strlen($hex) - 2; $x >= 0; $x = $x - 2) {
1249 $result .= substr($hex, $x, 2);
1264 $criteria =
'('.$this->getUserIdentifier().
'='.$ldapUser.
')';
1265 $justthese = array(
"objectsid");
1268 if ($this->serverType ==
"activedirectory") {
1269 $this->
bindauth($this->searchUser, $this->searchPassword);
1273 $searchDN = $this->people;
1276 $ldapSearchResult = @ldap_search($this->connection, $searchDN, $criteria, $justthese);
1278 if (!$ldapSearchResult) {
1279 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1283 $entry = ldap_first_entry($this->connection, $ldapSearchResult);
1287 $searchDN = $this->domain;
1296 $ldapBinary = ldap_get_values_len($this->connection, $entry,
"objectsid");
1300 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1314 $hex_sid = bin2hex($binsid);
1315 $rev = hexdec(substr($hex_sid, 0, 2));
1316 $subcount = hexdec(substr($hex_sid, 2, 2));
1317 $auth = hexdec(substr($hex_sid, 4, 12));
1318 $result =
"$rev-$auth";
1319 for ($x = 0; $x < $subcount; $x++) {
1320 $result .=
"-".hexdec($this->
littleEndian(substr($hex_sid, 16 + ($x * 8), 8)));
1341 dol_syslog(get_class($this).
"::search checkDn=".$checkDn.
" filter=".$filter);
1347 if ($this->serverType ==
"activedirectory") {
1348 $this->
bindauth($this->searchUser, $this->searchPassword);
1351 $this->result = @ldap_search($this->connection, $checkDn, $filter);
1353 $result = @ldap_get_entries($this->connection, $this->result);
1355 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1358 ldap_free_result($this->result);
1377 if ($this->serverType ==
"activedirectory") {
1378 $this->
bindauth($this->searchUser, $this->searchPassword);
1381 $searchDN = $this->people;
1386 dol_syslog(get_class($this).
"::fetch search with searchDN=".$searchDN.
" filter=".$filter);
1387 $this->result = @ldap_search($this->connection, $searchDN, $filter);
1388 if ($this->result) {
1389 $result = @ldap_get_entries($this->connection, $this->result);
1390 if ($result[
'count'] > 0) {
1391 dol_syslog(
'Ldap::fetch search found '.$result[
'count'].
' records');
1393 dol_syslog(
'Ldap::fetch search returns but found no records');
1397 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1398 dol_syslog(get_class($this).
"::fetch search fails");
1404 $searchDN = $this->domain;
1412 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1416 $this->firstname = $this->
convToOutputCharset($result[0][$this->attr_firstname][0], $this->ldapcharset);
1417 $this->login = $this->
convToOutputCharset($result[0][$this->attr_login][0], $this->ldapcharset);
1418 $this->phone = $this->
convToOutputCharset($result[0][$this->attr_phone][0], $this->ldapcharset);
1419 $this->fax = $this->
convToOutputCharset($result[0][$this->attr_fax][0], $this->ldapcharset);
1420 $this->mail = $this->
convToOutputCharset($result[0][$this->attr_mail][0], $this->ldapcharset);
1421 $this->mobile = $this->
convToOutputCharset($result[0][$this->attr_mobile][0], $this->ldapcharset);
1424 if (isset($result[0][
"pwdlastset"][0])) {
1425 $this->pwdlastset = ($result[0][
"pwdlastset"][0] != 0) ? $this->
convertTime($this->
convToOutputCharset($result[0][
"pwdlastset"][0], $this->ldapcharset)) : 0;
1427 $this->pwdlastset = -1;
1429 if (!$this->
name && !$this->login) {
1430 $this->pwdlastset = -1;
1435 $domain = str_replace(
'dc=',
'', $this->domain);
1436 $domain = str_replace(
',',
'.', $domain);
1437 $this->domainFQDN = $domain;
1441 $this->ldapUserDN = $result[0][
'dn'];
1443 ldap_free_result($this->result);
1458 if ($this->serverType ==
"activedirectory") {
1459 return $this->attr_sambalogin;
1461 return $this->attr_login;
1475 "TRUSTED_TO_AUTH_FOR_DELEGATION" => 16777216,
1476 "PASSWORD_EXPIRED" => 8388608,
1477 "DONT_REQ_PREAUTH" => 4194304,
1478 "USE_DES_KEY_ONLY" => 2097152,
1479 "NOT_DELEGATED" => 1048576,
1480 "TRUSTED_FOR_DELEGATION" => 524288,
1481 "SMARTCARD_REQUIRED" => 262144,
1482 "MNS_LOGON_ACCOUNT" => 131072,
1483 "DONT_EXPIRE_PASSWORD" => 65536,
1484 "SERVER_TRUST_ACCOUNT" => 8192,
1485 "WORKSTATION_TRUST_ACCOUNT" => 4096,
1486 "INTERDOMAIN_TRUST_ACCOUNT" => 2048,
1487 "NORMAL_ACCOUNT" => 512,
1488 "TEMP_DUPLICATE_ACCOUNT" => 256,
1489 "ENCRYPTED_TEXT_PWD_ALLOWED" => 128,
1490 "PASSWD_CANT_CHANGE" => 64,
1491 "PASSWD_NOTREQD" => 32,
1493 "HOMEDIR_REQUIRED" => 8,
1494 "ACCOUNTDISABLE" => 2,
1501 foreach ($flags as $flag => $val) {
1502 if ($uacf >= $val) {
1504 $retval[$val] = $flag;
1521 805306368 =>
"NORMAL_ACCOUNT",
1522 805306369 =>
"WORKSTATION_TRUST",
1523 805306370 =>
"INTERDOMAIN_TRUST",
1524 268435456 =>
"SECURITY_GLOBAL_GROUP",
1525 268435457 =>
"DISTRIBUTION_GROUP",
1526 536870912 =>
"SECURITY_LOCAL_GROUP",
1527 536870913 =>
"DISTRIBUTION_LOCAL_GROUP"
1531 foreach ($stypes as $sat => $val) {
1532 if ($samtype == $sat) {
1537 if (empty($retval)) {
1538 $retval =
"UNKNOWN_TYPE_".$samtype;
1552 $dateLargeInt = $value;
1553 $secsAfterADEpoch = $dateLargeInt / (10000000);
1554 $ADToUnixConvertor = ((1970 - 1601) * 365.242190) * 86400;
1555 $unixTimeStamp = intval($secsAfterADEpoch - $ADToUnixConvertor);
1556 return $unixTimeStamp;
1570 if ($pagecodefrom ==
'ISO-8859-1' && $conf->file->character_set_client ==
'UTF-8') {
1571 $str = mb_convert_encoding($str,
'UTF-8',
'ISO-8859-1');
1573 if ($pagecodefrom ==
'UTF-8' && $conf->file->character_set_client ==
'ISO-8859-1') {
1574 $str = mb_convert_encoding($str,
'ISO-8859-1');
1589 if ($pagecodeto ==
'ISO-8859-1' && $conf->file->character_set_client ==
'UTF-8') {
1590 $str = mb_convert_encoding($str,
'ISO-8859-1');
1592 if ($pagecodeto ==
'UTF-8' && $conf->file->character_set_client ==
'ISO-8859-1') {
1593 $str = mb_convert_encoding($str,
'UTF-8',
'ISO-8859-1');
1608 if (empty($keygroup)) {
1609 $keygroup =
'LDAP_KEY_GROUPS';
1613 $result = $this->
search($this->groups, $search);
1615 $c = $result[
'count'];
1617 for ($i = 0; $i < $c; $i++) {
1618 $gids[] = $result[$i][
'gidnumber'][0];
1622 return $gids[0] + 1;
Class to manage LDAP features.
add($dn, $info, $user)
Add an LDAP entry LDAP object connect and bind must have been done.
convertTime($value)
Converts ActiveDirectory time to Unix timestamp.
modify($dn, $info, $user)
Modify an LDAP entry LDAP object connect and bind must have been done.
deleteAttribute($dn, $info, $user)
Delete an LDAP attribute in entry LDAP object connect and bind must have been done.
setVersion()
Set LDAP protocol version.
convToOutputCharset($str, $pagecodefrom='UTF-8')
Convert a string into output/memory charset.
littleEndian($hex)
Converts a little-endian hex-number to one, that 'hexdec' can convert Required by Active Directory.
fetch($user, $filter)
Load all attributes of an LDAP user.
update($dn, $info, $user, $olddn, $newrdn='', $newparent='')
Modify an LDAP entry (to use if dn != olddn) LDAP object connect and bind must have been done.
getObjectSid($ldapUser)
Gets LDAP user SID.
updateAttribute($dn, $info, $user)
Update an LDAP attribute in entry LDAP object connect and bind must have been done.
getUserIdentifier()
Returns the correct user identifier to use, based on the LDAP server type.
getAttribute($dn, $filter)
Returns an array containing attributes and values for first record.
close()
Simply closes the connection set up earlier.
parseSAT($samtype)
SamAccountType value to text.
rename($dn, $newrdn, $newparent, $user, $deleteoldrdn=true)
Rename an LDAP entry LDAP object connect and bind must have been done.
getNextGroupGid($keygroup='LDAP_KEY_GROUPS')
Return available value of group GID.
setSizeLimit()
Set LDAP size limit.
binSIDtoText($binsid)
Returns the textual SID Required by Active Directory.
connectBind()
Connect and bind Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType,...
setReferrals()
Set LDAP referrals.
search($checkDn, $filter)
Search method with filter this->connection must be defined.
getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0, $attributeAsArray=array())
Returns an array containing a details or list of LDAP record(s).
getVersion()
Verify LDAP server version.
dumpContent($dn, $info)
Build an LDAP message.
getAttributeValues($filterrecord, $attribute)
Returns an array containing values for an attribute and for first record matching filterrecord.
parseUACF($uacf)
UserAccountControl Flags to more human understandable form...
__construct()
Constructor.
convFromOutputCharset($str, $pagecodeto='UTF-8')
Convert a string from output/memory charset.
serverPing($host, $port=389, $timeout=1)
Ping a server before ldap_connect for avoid waiting.
bind()
Anonymously binds to the connection.
unbind()
Unbind of LDAP server (close connection).
bindauth($bindDn, $pass)
Binds as an authenticated user, which usually allows for write access.
dump($dn, $info)
Dump an LDAP message to ldapinput.in file.
addAttribute($dn, $info, $user)
Add an LDAP attribute in entry LDAP object connect and bind must have been done.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.