44 public $errors = array();
113 public $ldapcharset =
'UTF-8';
149 if (!empty($conf->global->LDAP_SERVER_HOST)) {
150 $this->server[] = $conf->global->LDAP_SERVER_HOST;
152 if (!empty($conf->global->LDAP_SERVER_HOST_SLAVE)) {
153 $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE;
200 $this->connectedServer =
'';
203 if (count($this->server) == 0 || empty($this->server[0])) {
204 $this->error =
'LDAP setup (file conf.php) is not complete';
205 dol_syslog(get_class($this).
"::connect_bind ".$this->error, LOG_WARNING);
209 if (!function_exists(
"ldap_connect")) {
210 $this->error =
'LDAPFunctionsNotAvailableOnPHP';
211 dol_syslog(get_class($this).
"::connect_bind ".$this->error, LOG_WARNING);
215 if (empty($this->error)) {
217 foreach ($this->server as $host) {
225 if ($this->
serverPing($host, $this->serverPort) ===
true) {
226 $this->connection = ldap_connect($host, $this->serverPort);
228 if (preg_match(
'/^ldaps/i', $host)) {
231 $this->connection = ldap_connect($host, $this->serverPort);
237 if (is_resource($this->connection) || is_object($this->connection)) {
239 if (!empty($conf->global->LDAP_SERVER_USE_TLS)) {
245 $resulttls = ldap_start_tls($this->connection);
247 dol_syslog(get_class($this).
"::connect_bind failed to start tls", LOG_WARNING);
248 $this->error =
'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).
' '.ldap_error($this->connection);
256 ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0);
259 if ($this->serverType ==
"activedirectory") {
261 dol_syslog(get_class($this).
"::connect_bind try bindauth for activedirectory on ".$host.
" user=".$this->searchUser.
" password=".preg_replace(
'/./',
'*', $this->searchPassword), LOG_DEBUG);
262 $this->result = $this->
bindauth($this->searchUser, $this->searchPassword);
266 $this->connectedServer = $host;
269 $this->error = ldap_errno($this->connection).
' '.ldap_error($this->connection);
273 if ($this->searchUser && $this->searchPassword) {
274 dol_syslog(get_class($this).
"::connect_bind try bindauth on ".$host.
" user=".$this->searchUser.
" password=".preg_replace(
'/./',
'*', $this->searchPassword), LOG_DEBUG);
275 $this->result = $this->
bindauth($this->searchUser, $this->searchPassword);
279 $this->connectedServer = $host;
282 $this->error = ldap_errno($this->connection).
' '.ldap_error($this->connection);
287 dol_syslog(get_class($this).
"::connect_bind try bind anonymously on ".$host, LOG_DEBUG);
292 $this->connectedServer = $host;
295 $this->error = ldap_errno($this->connection).
' '.ldap_error($this->connection);
308 $return = $connected;
309 dol_syslog(get_class($this).
"::connect_bind return=".$return, LOG_DEBUG);
311 $this->error =
'Failed to connect to LDAP'.($this->error ?
': '.$this->error :
'');
313 dol_syslog(get_class($this).
"::connect_bind return=".$return.
' - '.$this->error, LOG_WARNING);
329 $r_type = get_resource_type($this->connection);
330 if ($this->connection && ($r_type ===
"Unknown" || !@ldap_close($this->connection))) {
345 if (!$this->result = @ldap_bind($this->connection)) {
346 $this->ldapErrorCode = ldap_errno($this->connection);
347 $this->ldapErrorText = ldap_error($this->connection);
367 if (!$this->result = @ldap_bind($this->connection, $bindDn, $pass)) {
368 $this->ldapErrorCode = ldap_errno($this->connection);
369 $this->ldapErrorText = ldap_error($this->connection);
385 $this->result =
true;
386 if ($this->connection) {
387 $this->result = @ldap_unbind($this->connection);
405 $version = @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version);
417 $ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion);
418 return $ldapsetversion;
429 $ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
430 return $ldapreferrals;
445 dol_syslog(get_class($this).
"::add dn=".
$dn.
" info=".json_encode($info));
448 if (!$this->connection) {
449 $this->error =
"NotConnected";
453 $this->error =
"NotConnected";
459 foreach ($info as $key => $val) {
460 if (!is_array($val)) {
468 $result = @ldap_add($this->connection,
$dn, $info);
471 dol_syslog(get_class($this).
"::add successfull", LOG_DEBUG);
474 $this->ldapErrorCode = @ldap_errno($this->connection);
475 $this->ldapErrorText = @ldap_error($this->connection);
477 dol_syslog(get_class($this).
"::add failed: ".$this->error, LOG_ERR);
493 dol_syslog(get_class($this).
"::modify dn=".
$dn.
" info=".join(
',', $info));
496 if (!$this->connection) {
497 $this->error =
"NotConnected";
501 $this->error =
"NotConnected";
507 foreach ($info as $key => $val) {
508 if (!is_array($val)) {
518 if ($this->serverType ==
"activedirectory") {
522 if (isset($info[
'unicodePwd'])) {
523 $info[
'unicodePwd'] = mb_convert_encoding(
"\"".$info[
'unicodePwd'].
"\"",
"UTF-16LE",
"UTF-8");
526 $result = @ldap_modify($this->connection,
$dn, $info);
529 dol_syslog(get_class($this).
"::modify successfull", LOG_DEBUG);
532 $this->error = @ldap_error($this->connection);
533 dol_syslog(get_class($this).
"::modify failed: ".$this->error, LOG_ERR);
549 public function rename(
$dn, $newrdn, $newparent, $user, $deleteoldrdn =
true)
551 dol_syslog(get_class($this).
"::modify dn=".
$dn.
" newrdn=".$newrdn.
" newparent=".$newparent.
" deleteoldrdn=".($deleteoldrdn ? 1 : 0));
554 if (!$this->connection) {
555 $this->error =
"NotConnected";
559 $this->error =
"NotConnected";
569 $result = @ldap_rename($this->connection,
$dn, $newrdn, $newparent, $deleteoldrdn);
572 dol_syslog(get_class($this).
"::rename successfull", LOG_DEBUG);
575 $this->error = @ldap_error($this->connection);
576 dol_syslog(get_class($this).
"::rename failed: ".$this->error, LOG_ERR);
593 public function update(
$dn, $info, $user, $olddn, $newrdn =
false, $newparent =
false)
595 dol_syslog(get_class($this).
"::update dn=".
$dn.
" olddn=".$olddn);
598 if (!$this->connection) {
599 $this->error =
"NotConnected";
603 $this->error =
"NotConnected";
607 if (!$olddn || $olddn !=
$dn) {
608 if (!empty($olddn) && !empty($newrdn) && !empty($newparent) && $this->ldapProtocolVersion ===
'3') {
610 $result = $this->
rename($olddn, $newrdn, $newparent, $user,
true);
616 $result = $this->
delete($olddn);
625 $this->error = ldap_error($this->connection).
' (Code '.ldap_errno($this->connection).
") ".$this->error;
626 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
630 dol_syslog(get_class($this).
"::update done successfully");
643 public function delete(
$dn)
645 dol_syslog(get_class($this).
"::delete Delete LDAP entry dn=".
$dn);
648 if (!$this->connection) {
649 $this->error =
"NotConnected";
653 $this->error =
"NotConnected";
660 $result = @ldap_delete($this->connection, $dn);
682 if (preg_match(
'/^ldap/', $this->server[0])) {
683 $target =
"-H ".join(
',', $this->server);
685 $target =
"-h ".join(
',', $this->server).
" -p ".$this->serverPort;
687 $content .=
"# ldapadd $target -c -v -D ".$this->searchUser.
" -W -f ldapinput.in\n";
688 $content .=
"# ldapmodify $target -c -v -D ".$this->searchUser.
" -W -f ldapinput.in\n";
689 $content .=
"# ldapdelete $target -c -v -D ".$this->searchUser.
" -W -f ldapinput.in\n";
690 if (in_array(
'localhost', $this->server)) {
691 $content .=
"# If commands fails to connect, try without -h and -p\n";
693 $content .=
"dn: ".$dn.
"\n";
694 foreach ($info as $key => $value) {
695 if (!is_array($value)) {
696 $content .=
"$key: $value\n";
698 foreach ($value as $valuevalue) {
699 $content .=
"$key: $valuevalue\n";
723 $outputfile = $conf->ldap->dir_temp.
'/ldapinput.in';
724 $fp = fopen($outputfile,
"w");
726 fputs($fp, $content);
728 if (!empty($conf->global->MAIN_UMASK)) {
729 @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
748 if (preg_match(
'/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs)) {
750 $host =
'ssl://'.$regs[1];
751 } elseif (preg_match(
'/^ldap:\/\/([^\/]+)\/?$/', $host, $regs)) {
760 $errno = $errstr = 0;
769 $op = @fsockopen($host, $port, $errno, $errstr, $timeout);
794 dol_syslog(get_class($this).
"::addAttribute dn=".
$dn.
" info=".join(
',', $info));
797 if (!$this->connection) {
798 $this->error =
"NotConnected";
802 $this->error =
"NotConnected";
808 foreach ($info as $key => $val) {
809 if (!is_array($val)) {
817 $result = @ldap_mod_add($this->connection,
$dn, $info);
820 dol_syslog(get_class($this).
"::add_attribute successfull", LOG_DEBUG);
823 $this->error = @ldap_error($this->connection);
824 dol_syslog(get_class($this).
"::add_attribute failed: ".$this->error, LOG_ERR);
840 dol_syslog(get_class($this).
"::updateAttribute dn=".
$dn.
" info=".join(
',', $info));
843 if (!$this->connection) {
844 $this->error =
"NotConnected";
848 $this->error =
"NotConnected";
854 foreach ($info as $key => $val) {
855 if (!is_array($val)) {
863 $result = @ldap_mod_replace($this->connection,
$dn, $info);
866 dol_syslog(get_class($this).
"::updateAttribute successfull", LOG_DEBUG);
869 $this->error = @ldap_error($this->connection);
870 dol_syslog(get_class($this).
"::updateAttribute failed: ".$this->error, LOG_ERR);
886 dol_syslog(get_class($this).
"::deleteAttribute dn=".
$dn.
" info=".join(
',', $info));
889 if (!$this->connection) {
890 $this->error =
"NotConnected";
894 $this->error =
"NotConnected";
900 foreach ($info as $key => $val) {
901 if (!is_array($val)) {
909 $result = @ldap_mod_del($this->connection,
$dn, $info);
912 dol_syslog(get_class($this).
"::deleteAttribute successfull", LOG_DEBUG);
915 $this->error = @ldap_error($this->connection);
916 dol_syslog(get_class($this).
"::deleteAttribute failed: ".$this->error, LOG_ERR);
931 if (!$this->connection) {
932 $this->error =
"NotConnected";
936 $this->error =
"NotConnected";
940 $search = @ldap_search($this->connection,
$dn, $filter);
943 $entry = @ldap_first_entry($this->connection, $search);
946 $this->ldapErrorCode = -1;
947 $this->ldapErrorText =
"Couldn't find entry";
952 if (!($values = ldap_get_attributes($this->connection, $entry))) {
953 $this->ldapErrorCode = ldap_errno($this->connection);
954 $this->ldapErrorText = ldap_error($this->connection);
971 $attributes = array();
972 $attributes[0] = $attribute;
975 $this->result = @ldap_search($this->connection, $this->people, $filterrecord, $attributes);
981 $entry = ldap_first_entry($this->connection, $this->result);
984 $this->ldapErrorCode = -1;
985 $this->ldapErrorText =
"Couldn't find user";
990 if (!$values = @ldap_get_values($this->connection, $entry, $attribute)) {
991 $this->ldapErrorCode = ldap_errno($this->connection);
992 $this->ldapErrorText = ldap_error($this->connection);
1012 public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array())
1014 $fulllist = array();
1016 dol_syslog(get_class($this).
"::getRecords search=".$search.
" userDn=".$userDn.
" useridentifier=".$useridentifier.
" attributeArray=array(".join(
',', $attributeArray).
") activefilter=".$activefilter);
1019 if ($this->serverType ==
"activedirectory") {
1020 $this->
bindauth($this->searchUser, $this->searchPassword);
1021 dol_syslog(get_class($this).
"::bindauth serverType=activedirectory searchUser=".$this->searchUser);
1025 if (!empty($activefilter)) {
1026 if (((
string) $activefilter ==
'1' || (
string) $activefilter ==
'user') && $this->filter) {
1027 $filter =
'('.$this->filter.
')';
1028 } elseif (((
string) $activefilter ==
'group') && $this->filtergroup ) {
1029 $filter =
'('.$this->filtergroup.
')';
1030 } elseif (((
string) $activefilter ==
'member') && $this->filter) {
1031 $filter =
'('.$this->filtermember.
')';
1034 $filter =
'('.ldap_escape($useridentifier,
'', LDAP_ESCAPE_FILTER).
'=*)';
1037 $filter =
'('.ldap_escape($useridentifier,
'', LDAP_ESCAPE_FILTER).
'='.ldap_escape($search,
'', LDAP_ESCAPE_FILTER).
')';
1040 if (is_array($attributeArray)) {
1042 $attributeArray = array_values($attributeArray);
1043 dol_syslog(get_class($this).
"::getRecords connection=".$this->connection.
" userDn=".$userDn.
" filter=".$filter.
" attributeArray=(".join(
',', $attributeArray).
")");
1045 $this->result = @ldap_search($this->connection, $userDn, $filter, $attributeArray);
1048 dol_syslog(get_class($this).
"::getRecords connection=".$this->connection.
" userDn=".$userDn.
" filter=".$filter);
1049 $this->result = @ldap_search($this->connection, $userDn, $filter);
1051 if (!$this->result) {
1052 $this->error =
'LDAP search failed: '.ldap_errno($this->connection).
" ".ldap_error($this->connection);
1056 $info = @ldap_get_entries($this->connection, $this->result);
1062 for ($i = 0; $i < $info[
"count"]; $i++) {
1063 $recordid = $this->
convToOutputCharset($info[$i][strtolower($useridentifier)][0], $this->ldapcharset);
1066 $fulllist[$recordid][$useridentifier] = $recordid;
1069 $num = count($attributeArray);
1070 for ($j = 0; $j < $num; $j++) {
1071 $keyattributelower = strtolower($attributeArray[$j]);
1075 if ($this->serverType ==
"activedirectory" && $keyattributelower ==
"objectsid") {
1077 $fulllist[$recordid][$attributeArray[$j]] = $objectsid;
1079 if (in_array($attributeArray[$j], $attributeAsArray) && is_array($info[$i][$keyattributelower])) {
1080 $valueTab = array();
1081 foreach ($info[$i][$keyattributelower] as $key => $value) {
1084 $fulllist[$recordid][$attributeArray[$j]] = $valueTab;
1086 $fulllist[$recordid][$attributeArray[$j]] = $this->
convToOutputCharset($info[$i][$keyattributelower][0], $this->ldapcharset);
1107 for ($x =
dol_strlen($hex) - 2; $x >= 0; $x = $x - 2) {
1108 $result .= substr($hex, $x, 2);
1123 $criteria =
'('.$this->getUserIdentifier().
'='.$ldapUser.
')';
1124 $justthese = array(
"objectsid");
1127 if ($this->serverType ==
"activedirectory") {
1128 $this->
bindauth($this->searchUser, $this->searchPassword);
1135 $ldapSearchResult = @ldap_search($this->connection, $searchDN, $criteria, $justthese);
1137 if (!$ldapSearchResult) {
1138 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1142 $entry = ldap_first_entry($this->connection, $ldapSearchResult);
1155 $ldapBinary = ldap_get_values_len($this->connection, $entry,
"objectsid");
1159 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1173 $hex_sid = bin2hex($binsid);
1174 $rev = hexdec(substr($hex_sid, 0, 2));
1175 $subcount = hexdec(substr($hex_sid, 2, 2));
1176 $auth = hexdec(substr($hex_sid, 4, 12));
1178 for ($x = 0; $x < $subcount; $x++) {
1198 dol_syslog(get_class($this).
"::search checkDn=".$checkDn.
" filter=".$filter);
1204 if ($this->serverType ==
"activedirectory") {
1205 $this->
bindauth($this->searchUser, $this->searchPassword);
1208 $this->result = @ldap_search($this->connection, $checkDn, $filter);
1210 $result = @ldap_get_entries($this->connection, $this->result);
1212 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1215 ldap_free_result($this->result);
1234 if ($this->serverType ==
"activedirectory") {
1235 $this->
bindauth($this->searchUser, $this->searchPassword);
1243 dol_syslog(get_class($this).
"::fetch search with searchDN=".$searchDN.
" filter=".$filter);
1244 $this->result = @ldap_search($this->connection, $searchDN, $filter);
1245 if ($this->result) {
1246 $result = @ldap_get_entries($this->connection, $this->result);
1250 dol_syslog(
'Ldap::fetch search returns but found no records');
1254 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1255 dol_syslog(get_class($this).
"::fetch search fails");
1269 $this->error = ldap_errno($this->connection).
" ".ldap_error($this->connection);
1282 if (isset(
$result[0][
"pwdlastset"][0])) {
1285 $this->pwdlastset = -1;
1287 if (!$this->
name && !$this->login) {
1288 $this->pwdlastset = -1;
1293 $domain = str_replace(
'dc=',
'', $this->domain);
1299 $this->ldapUserDN =
$result[0][
'dn'];
1301 ldap_free_result($this->result);
1316 if ($this->serverType ==
"activedirectory") {
1317 return $this->attr_sambalogin;
1319 return $this->attr_login;
1333 "TRUSTED_TO_AUTH_FOR_DELEGATION" => 16777216,
1334 "PASSWORD_EXPIRED" => 8388608,
1335 "DONT_REQ_PREAUTH" => 4194304,
1336 "USE_DES_KEY_ONLY" => 2097152,
1337 "NOT_DELEGATED" => 1048576,
1338 "TRUSTED_FOR_DELEGATION" => 524288,
1339 "SMARTCARD_REQUIRED" => 262144,
1340 "MNS_LOGON_ACCOUNT" => 131072,
1341 "DONT_EXPIRE_PASSWORD" => 65536,
1342 "SERVER_TRUST_ACCOUNT" => 8192,
1343 "WORKSTATION_TRUST_ACCOUNT" => 4096,
1344 "INTERDOMAIN_TRUST_ACCOUNT" => 2048,
1345 "NORMAL_ACCOUNT" => 512,
1346 "TEMP_DUPLICATE_ACCOUNT" => 256,
1347 "ENCRYPTED_TEXT_PWD_ALLOWED" => 128,
1348 "PASSWD_CANT_CHANGE" => 64,
1349 "PASSWD_NOTREQD" => 32,
1351 "HOMEDIR_REQUIRED" => 8,
1352 "ACCOUNTDISABLE" => 2,
1359 foreach ($flags as $flag => $val) {
1360 if ($uacf >= $val) {
1362 $retval[$val] = $flag;
1379 805306368 =>
"NORMAL_ACCOUNT",
1380 805306369 =>
"WORKSTATION_TRUST",
1381 805306370 =>
"INTERDOMAIN_TRUST",
1382 268435456 =>
"SECURITY_GLOBAL_GROUP",
1383 268435457 =>
"DISTRIBUTION_GROUP",
1384 536870912 =>
"SECURITY_LOCAL_GROUP",
1385 536870913 =>
"DISTRIBUTION_LOCAL_GROUP"
1389 while (list($sat, $val) = each($stypes)) {
1390 if ($samtype == $sat) {
1395 if (empty($retval)) {
1396 $retval =
"UNKNOWN_TYPE_".$samtype;
1412 $dateLargeInt = $value;
1413 $secsAfterADEpoch = $dateLargeInt / (10000000);
1414 $ADToUnixConvertor = ((1970 - 1601) * 365.242190) * 86400;
1415 $unixTimeStamp = intval($secsAfterADEpoch - $ADToUnixConvertor);
1416 return $unixTimeStamp;
1430 if ($pagecodefrom ==
'ISO-8859-1' && $conf->file->character_set_client ==
'UTF-8') {
1431 $str = utf8_encode($str);
1433 if ($pagecodefrom ==
'UTF-8' && $conf->file->character_set_client ==
'ISO-8859-1') {
1434 $str = utf8_decode($str);
1449 if ($pagecodeto ==
'ISO-8859-1' && $conf->file->character_set_client ==
'UTF-8') {
1450 $str = utf8_decode($str);
1452 if ($pagecodeto ==
'UTF-8' && $conf->file->character_set_client ==
'ISO-8859-1') {
1453 $str = utf8_encode($str);
1469 if (empty($keygroup)) {
1470 $keygroup =
'LDAP_KEY_GROUPS';
1473 $search =
'('.$conf->global->$keygroup.
'=*)';
1478 for ($i = 0; $i < $c; $i++) {
1479 $gids[] =
$result[$i][
'gidnumber'][0];
1483 return $gids[0] + 1;
setReferrals()
changement du referrals.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
deleteAttribute($dn, $info, $user)
Delete a LDAP attribute in entry Ldap object connect and bind must have been done.
getNextGroupGid($keygroup= 'LDAP_KEY_GROUPS')
Return available value of group GID.
update($dn, $info, $user, $olddn, $newrdn=false, $newparent=false)
Modify a LDAP entry (to use if dn != olddn) Ldap object connect and bind must have been done...
addAttribute($dn, $info, $user)
Add a LDAP attribute in entry Ldap object connect and bind must have been done.
binSIDtoText($binsid)
Returns the textual SID Indispensable pour Active Directory.
add($dn, $info, $user)
Add a LDAP entry Ldap object connect and bind must have been done.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
modify($dn, $info, $user)
Modify a LDAP entry Ldap object connect and bind must have been done.
const SYNCHRO_NONE
No Ldap synchronization.
$connectedServer
Current connected server.
getVersion()
Verification de la version du serveur ldap.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
$ldapErrorCode
Code erreur retourne par le serveur Ldap.
getAttribute($dn, $filter)
Returns an array containing attributes and values for first record.
const SYNCHRO_DOLIBARR_TO_LDAP
Dolibarr to Ldap synchronization.
$searchUser
User administrateur Ldap Active Directory ne supporte pas les connexions anonymes.
$ldapErrorText
Message texte de l'erreur.
getAttributeValues($filterrecord, $attribute)
Returns an array containing values for an attribute and for first record matching filterrecord...
unbind()
Unbind of LDAP server (close connection).
$conf db name
Only used if Module[ID]Name translation string is not found.
bind()
Anonymously binds to the connection.
parseUACF($uacf)
UserAccountControl Flgs to more human understandable form...
convFromOutputCharset($str, $pagecodeto= 'UTF-8')
Convert a string from output/memory charset.
convert_time($value)
Convertit le temps ActiveDirectory en Unix timestamp.
$ldapProtocolVersion
Version du protocole ldap.
updateAttribute($dn, $info, $user)
Update a LDAP attribute in entry Ldap object connect and bind must have been done.
$people
DN des utilisateurs.
$searchPassword
Mot de passe de l'administrateur Active Directory ne supporte pas les connexions anonymes.
$result
Result of any connections etc.
convToOutputCharset($str, $pagecodefrom= 'UTF-8')
Convert a string into output/memory charset.
dump($dn, $info)
Dump a LDAP message to ldapinput.in file.
serverPing($host, $port=389, $timeout=1)
Ping a server before ldap_connect for avoid waiting.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dump_content($dn, $info)
Build a LDAP message.
bindauth($bindDn, $pass)
Binds as an authenticated user, which usually allows for write access.
getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0, $attributeAsArray=array())
Returns an array containing a details or list of LDAP record(s) ldapsearch -LLLx -hlocalhost -Dcn=adm...
parseSAT($samtype)
SamAccountType value to text.
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
__construct()
Constructor.
search($checkDn, $filter)
Fonction de recherche avec filtre this->connection doit etre defini donc la methode bind ou bindauth d...
littleEndian($hex)
Converts a little-endian hex-number to one, that 'hexdec' can convert Required by Active Directory...
Class to manage LDAP features.
close()
Simply closes the connection set up earlier.
rename($dn, $newrdn, $newparent, $user, $deleteoldrdn=true)
Rename a LDAP entry Ldap object connect and bind must have been done.
fetch($user, $filter)
Load all attribute of a LDAP user.
setVersion()
Change ldap protocol version to use.
getObjectSid($ldapUser)
Recupere le SID de l'utilisateur Required by Active Directory.
$server
Tableau des serveurs (IP addresses ou nom d'hotes)
getUserIdentifier()
Returns the correct user identifier to use, based on the ldap server type.
$connection
The internal LDAP connection handle.
$serverType
type de serveur, actuellement OpenLdap et Active Directory
connect_bind()
Connect and bind Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword After return, this->connection and $this->bind are defined.