dolibarr 21.0.4
ldap.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
4 * Copyright (C) 2005-2021 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2006-2021 Laurent Destailleur <eldy@users.sourceforge.net>
6 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 * or see https://www.gnu.org/
23 */
24
38class Ldap
39{
43 public $error = '';
44
48 public $errors = array();
49
53 public $server = array();
54
58 public $connectedServer;
59
63 public $serverPort;
64
69 public $dn;
74 public $serverType;
79 public $ldapProtocolVersion;
84 public $domain;
85
89 public $domainFQDN;
90
94 public $bind;
95
100 public $searchUser;
105 public $searchPassword;
106
110 public $people;
111
115 public $groups;
116
120 public $ldapErrorCode;
121
125 public $ldapErrorText;
126
130 public $filter;
131
135 public $filtergroup;
136
140 public $filtermember;
141
145 public $attr_login;
146
150 public $attr_sambalogin;
151
155 public $attr_name;
156
160 public $attr_firstname;
161
165 public $attr_mail;
166
170 public $attr_phone;
171
175 public $attr_fax;
176
180 public $attr_mobile;
181
185 public $badpwdtime;
186
190 public $ldapUserDN;
191
195 public $name;
196
200 public $firstname;
201
205 public $login;
206
210 public $phone;
211
215 public $fax;
216
220 public $mail;
221
225 public $mobile;
226
230 public $uacf;
231
235 public $pwdlastset;
236
241 public $ldapcharset = 'UTF-8';
242
246 public $connection;
247
251 public $result;
252
256 const SYNCHRO_NONE = 0;
257
261 const SYNCHRO_DOLIBARR_TO_LDAP = 1;
262
266 const SYNCHRO_LDAP_TO_DOLIBARR = 2;
267
271 public function __construct()
272 {
273
274 // Server
275 if (getDolGlobalString('LDAP_SERVER_HOST')) {
276 $this->server[] = getDolGlobalString('LDAP_SERVER_HOST');
277 }
278 if (getDolGlobalString('LDAP_SERVER_HOST_SLAVE')) {
279 $this->server[] = getDolGlobalString('LDAP_SERVER_HOST_SLAVE');
280 }
281 $this->serverPort = getDolGlobalInt('LDAP_SERVER_PORT', 389);
282 $this->ldapProtocolVersion = getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION');
283 $this->dn = getDolGlobalString('LDAP_SERVER_DN');
284 $this->serverType = getDolGlobalString('LDAP_SERVER_TYPE');
285
286 $this->domain = getDolGlobalString('LDAP_SERVER_DN');
287 $this->searchUser = getDolGlobalString('LDAP_ADMIN_DN');
288 $this->searchPassword = getDolGlobalString('LDAP_ADMIN_PASS');
289 $this->people = getDolGlobalString('LDAP_USER_DN');
290 $this->groups = getDolGlobalString('LDAP_GROUP_DN');
291
292 $this->filter = getDolGlobalString('LDAP_FILTER_CONNECTION'); // Filter on user
293 $this->filtergroup = getDolGlobalString('LDAP_GROUP_FILTER'); // Filter on groups
294 $this->filtermember = getDolGlobalString('LDAP_MEMBER_FILTER'); // Filter on member
295
296 // Users
297 $this->attr_login = getDolGlobalString('LDAP_FIELD_LOGIN'); //unix
298 $this->attr_sambalogin = getDolGlobalString('LDAP_FIELD_LOGIN_SAMBA'); //samba, activedirectory
299 $this->attr_name = getDolGlobalString('LDAP_FIELD_NAME');
300 $this->attr_firstname = getDolGlobalString('LDAP_FIELD_FIRSTNAME');
301 $this->attr_mail = getDolGlobalString('LDAP_FIELD_MAIL');
302 $this->attr_phone = getDolGlobalString('LDAP_FIELD_PHONE');
303 $this->attr_fax = getDolGlobalString('LDAP_FIELD_FAX');
304 $this->attr_mobile = getDolGlobalString('LDAP_FIELD_MOBILE');
305 }
306
307 // Connection handling methods -------------------------------------------
308
317 public function connectBind()
318 {
319 global $dolibarr_main_auth_ldap_debug;
320
321 $connected = 0;
322 $this->bind = false;
323 $this->error = '';
324 $this->connectedServer = '';
325
326 $ldapdebug = !((empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false"));
327
328 if ($ldapdebug) {
329 dol_syslog(get_class($this)."::connectBind");
330 print "DEBUG: connectBind<br>\n";
331 }
332
333 // Check parameters
334 if (count($this->server) == 0 || empty($this->server[0])) {
335 $this->error = 'LDAP setup (file conf.php) is not complete';
336 dol_syslog(get_class($this)."::connectBind ".$this->error, LOG_WARNING);
337 return -1;
338 }
339
340 if (!function_exists("ldap_connect")) {
341 $this->error = 'LDAPFunctionsNotAvailableOnPHP';
342 dol_syslog(get_class($this)."::connectBind ".$this->error, LOG_WARNING);
343 return -1;
344 }
345
346 if (empty($this->error)) {
347 // Loop on each ldap server
348 foreach ($this->server as $host) {
349 if ($connected) {
350 break;
351 }
352 if (empty($host)) {
353 continue;
354 }
355
356 if ($this->serverPing($host, $this->serverPort)) {
357 if ($ldapdebug) {
358 dol_syslog(get_class($this)."::connectBind serverPing true, we try ldap_connect to ".$host, LOG_DEBUG);
359 }
360 if (version_compare(PHP_VERSION, '8.3.0', '>=')) {
361 // Since PHP 8.3, ldap_connect() expects a single URI argument. A scheme-less
362 // host (ex: localhost, 192.168.0.2) must be turned into a valid ldap:// URI,
363 // otherwise the host is parsed as the URI scheme and the later bind fails.
364 $uri = preg_match('/^ldaps?:\/\//i', $host) ? $host : 'ldap://'.$host.':'.$this->serverPort;
365 $this->connection = ldap_connect($uri);
366 } else {
367 $this->connection = ldap_connect($host, $this->serverPort);
368 }
369 } else {
370 if (preg_match('/^ldaps/i', $host)) {
371 // With host = ldaps://server, the serverPing to ssl://server sometimes fails, even if the ldap_connect succeed, so
372 // we test this case and continue in such a case even if serverPing fails.
373 if ($ldapdebug) {
374 dol_syslog(get_class($this)."::connectBind serverPing false, we try ldap_connect to ".$host, LOG_DEBUG);
375 }
376 if (version_compare(PHP_VERSION, '8.3.0', '>=')) {
377 $uri = preg_match('/^ldaps?:\/\//i', $host) ? $host : 'ldap://'.$host.':'.$this->serverPort;
378 $this->connection = ldap_connect($uri);
379 } else {
380 $this->connection = ldap_connect($host, $this->serverPort);
381 }
382 } else {
383 if ($ldapdebug) {
384 dol_syslog(get_class($this)."::connectBind serverPing false, no ldap_connect ".$host, LOG_DEBUG);
385 }
386 continue;
387 }
388 }
389
390 if (is_resource($this->connection) || is_object($this->connection)) {
391 if ($ldapdebug) {
392 dol_syslog(get_class($this)."::connectBind this->connection is ok", LOG_DEBUG);
393 }
394
395 // Upgrade connection to TLS, if requested by the configuration
396 if (getDolGlobalString('LDAP_SERVER_USE_TLS')) {
397 // For test/debug
398 //ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7);
399 //ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3);
400 //ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
401
402 $resulttls = ldap_start_tls($this->connection);
403 if (!$resulttls) {
404 dol_syslog(get_class($this)."::connectBind failed to start tls", LOG_WARNING);
405 $this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection);
406 $connected = 0;
407 $this->unbind();
408 }
409 }
410
411 // Execute the ldap_set_option here (after connect and before bind)
412 $this->setVersion();
413 $this->setSizeLimit();
414
415 if ($this->serverType == "activedirectory") {
416 $result = $this->setReferrals();
417 dol_syslog(get_class($this)."::connectBind try bindauth for activedirectory on ".$host." user=".$this->searchUser." password=".preg_replace('/./', '*', $this->searchPassword), LOG_DEBUG);
418 $this->result = $this->bindauth($this->searchUser, $this->searchPassword);
419 if ($this->result) {
420 $this->bind = $this->result;
421 $connected = 2;
422 $this->connectedServer = $host;
423 break;
424 } else {
425 $this->error = ldap_errno($this->connection).' '.ldap_error($this->connection);
426 }
427 } else {
428 // Try in auth mode
429 if ($this->searchUser && $this->searchPassword) {
430 dol_syslog(get_class($this)."::connectBind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./', '*', $this->searchPassword), LOG_DEBUG);
431 $this->result = $this->bindauth($this->searchUser, $this->searchPassword);
432 if ($this->result) {
433 $this->bind = $this->result;
434 $connected = 2;
435 $this->connectedServer = $host;
436 break;
437 } else {
438 $this->error = ldap_errno($this->connection).' '.ldap_error($this->connection);
439 }
440 }
441 // Try in anonymous
442 if (!$this->bind) {
443 dol_syslog(get_class($this)."::connectBind try bind anonymously on ".$host, LOG_DEBUG);
444 $result = $this->bind();
445 if ($result) {
446 $this->bind = $this->result;
447 $connected = 1;
448 $this->connectedServer = $host;
449 break;
450 } else {
451 $this->error = ldap_errno($this->connection).' '.ldap_error($this->connection);
452 }
453 }
454 }
455 }
456
457 if (!$connected) {
458 $this->unbind();
459 }
460 } // End loop on each server
461 }
462
463 if ($connected) {
464 dol_syslog(get_class($this)."::connectBind ".$connected, LOG_DEBUG);
465 return $connected;
466 } else {
467 $this->error = 'Failed to connect to LDAP'.($this->error ? ': '.$this->error : '');
468 dol_syslog(get_class($this)."::connectBind ".$this->error, LOG_WARNING);
469 return -1;
470 }
471 }
472
481 public function close()
482 {
483 return $this->unbind();
484 }
485
492 public function bind()
493 {
494 if (!$this->result = @ldap_bind($this->connection)) {
495 $this->ldapErrorCode = ldap_errno($this->connection);
496 $this->ldapErrorText = ldap_error($this->connection);
497 $this->error = $this->ldapErrorCode." ".$this->ldapErrorText;
498 return false;
499 } else {
500 return true;
501 }
502 }
503
514 public function bindauth($bindDn, $pass)
515 {
516 if (!$this->result = @ldap_bind($this->connection, $bindDn, $pass)) {
517 $this->ldapErrorCode = ldap_errno($this->connection);
518 $this->ldapErrorText = ldap_error($this->connection);
519 $this->error = $this->ldapErrorCode." ".$this->ldapErrorText;
520 return false;
521 } else {
522 return true;
523 }
524 }
525
532 public function unbind()
533 {
534 $this->result = true;
535 if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
536 if (is_object($this->connection)) {
537 try {
538 $this->result = ldap_unbind($this->connection);
539 } catch (Throwable $exception) {
540 $this->error = 'Failed to unbind LDAP connection: '.$exception;
541 $this->result = false;
542 dol_syslog(get_class($this).'::unbind - '.$this->error, LOG_WARNING);
543 }
544 }
545 } else {
546 if (is_resource($this->connection)) {
547 // @phan-suppress-next-line PhanTypeMismatchArgumentInternalReal
548 $this->result = @ldap_unbind($this->connection);
549 }
550 }
551 if ($this->result) {
552 return true;
553 } else {
554 return false;
555 }
556 }
557
558
564 public function getVersion()
565 {
566 @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version);
567 return $version;
568 }
569
576 public function setVersion()
577 {
578 return ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion);
579 }
580
586 public function setSizeLimit()
587 {
588 return ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0);
589 }
590
597 public function setReferrals()
598 {
599 return ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
600 }
601
602
612 public function add($dn, $info, $user)
613 {
614 dol_syslog(get_class($this)."::add dn=".$dn." info=".print_r($info, true));
615
616 // Check parameters
617 if (!$this->connection) {
618 $this->error = "NotConnected";
619 return -2;
620 }
621 if (!$this->bind) {
622 $this->error = "NotConnected";
623 return -3;
624 }
625
626 // Encode to LDAP page code
627 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
628 foreach ($info as $key => $val) {
629 if (!is_array($val)) {
630 $info[$key] = $this->convFromOutputCharset($val, $this->ldapcharset);
631 }
632 }
633
634 $this->dump($dn, $info);
635
636 //print_r($info);
637 $result = @ldap_add($this->connection, $dn, $info);
638
639 if ($result) {
640 dol_syslog(get_class($this)."::add successful", LOG_DEBUG);
641 return 1;
642 } else {
643 $this->ldapErrorCode = @ldap_errno($this->connection);
644 $this->ldapErrorText = @ldap_error($this->connection);
645 $this->error = $this->ldapErrorCode." ".$this->ldapErrorText;
646 dol_syslog(get_class($this)."::add failed: ".$this->error, LOG_ERR);
647 return -1;
648 }
649 }
650
660 public function modify($dn, $info, $user)
661 {
662 dol_syslog(get_class($this)."::modify dn=".$dn." info=".print_r($info, true));
663
664 // Check parameters
665 if (!$this->connection) {
666 $this->error = "NotConnected";
667 return -2;
668 }
669 if (!$this->bind) {
670 $this->error = "NotConnected";
671 return -3;
672 }
673
674 // Encode to LDAP page code
675 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
676 foreach ($info as $key => $val) {
677 if (!is_array($val)) {
678 $info[$key] = $this->convFromOutputCharset($val, $this->ldapcharset);
679 }
680 }
681
682 $this->dump($dn, $info);
683
684 //print_r($info);
685
686 // For better compatibility with Samba4 AD
687 if ($this->serverType == "activedirectory") {
688 unset($info['cn']); // To avoid error : Operation not allowed on RDN (Code 67)
689
690 // To avoid error : LDAP Error: 53 (Unwilling to perform)
691 if (isset($info['unicodePwd'])) {
692 $info['unicodePwd'] = mb_convert_encoding("\"".$info['unicodePwd']."\"", "UTF-16LE", "UTF-8");
693 }
694 }
695 $result = @ldap_mod_replace($this->connection, $dn, $info);
696
697 if ($result) {
698 dol_syslog(get_class($this)."::modify successful", LOG_DEBUG);
699 return 1;
700 } else {
701 $this->error = @ldap_error($this->connection);
702 dol_syslog(get_class($this)."::modify failed: ".$this->error, LOG_ERR);
703 return -1;
704 }
705 }
706
718 public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true)
719 {
720 dol_syslog(get_class($this)."::modify dn=".$dn." newrdn=".$newrdn." newparent=".$newparent." deleteoldrdn=".($deleteoldrdn ? 1 : 0));
721
722 // Check parameters
723 if (!$this->connection) {
724 $this->error = "NotConnected";
725 return -2;
726 }
727 if (!$this->bind) {
728 $this->error = "NotConnected";
729 return -3;
730 }
731
732 // Encode to LDAP page code
733 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
734 $newrdn = $this->convFromOutputCharset($newrdn, $this->ldapcharset);
735 $newparent = $this->convFromOutputCharset($newparent, $this->ldapcharset);
736
737 //print_r($info);
738 $result = @ldap_rename($this->connection, $dn, $newrdn, $newparent, $deleteoldrdn);
739
740 if ($result) {
741 dol_syslog(get_class($this)."::rename successful", LOG_DEBUG);
742 return 1;
743 } else {
744 $this->error = @ldap_error($this->connection);
745 dol_syslog(get_class($this)."::rename failed: ".$this->error, LOG_ERR);
746 return -1;
747 }
748 }
749
762 public function update($dn, $info, $user, $olddn, $newrdn = '', $newparent = '')
763 {
764 dol_syslog(get_class($this)."::update dn=".$dn." olddn=".$olddn);
765
766 // Check parameters
767 if (!$this->connection) {
768 $this->error = "NotConnected";
769 return -2;
770 }
771 if (!$this->bind) {
772 $this->error = "NotConnected";
773 return -3;
774 }
775
776 if (!$olddn || $olddn != $dn) {
777 if (!empty($olddn) && !empty($newrdn) && !empty($newparent) && $this->ldapProtocolVersion === '3') {
778 // This function currently only works with LDAPv3
779 $result = $this->rename($olddn, $newrdn, $newparent, $user, true);
780 $result = $this->modify($dn, $info, $user); // We force "modify" for avoid some fields not modify
781 } else {
782 // If change we make is rename the key of LDAP record, we create new one and if ok, we delete old one.
783 $result = $this->add($dn, $info, $user);
784 if ($result > 0 && $olddn && $olddn != $dn) {
785 $result = $this->delete($olddn); // If add fails, we do not try to delete old one
786 }
787 }
788 } else {
789 //$result = $this->delete($olddn);
790 $result = $this->add($dn, $info, $user); // If record has been deleted from LDAP, we recreate it. We ignore error if it already exists.
791 $result = $this->modify($dn, $info, $user); // We use add/modify instead of delete/add when olddn is received
792 }
793 if ($result <= 0) {
794 $this->error = ldap_error($this->connection).' (Code '.ldap_errno($this->connection).") ".$this->error;
795 dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
796 //print_r($info);
797 return -1;
798 } else {
799 dol_syslog(get_class($this)."::update done successfully");
800 return 1;
801 }
802 }
803
804
812 public function delete($dn)
813 {
814 dol_syslog(get_class($this)."::delete Delete LDAP entry dn=".$dn);
815
816 // Check parameters
817 if (!$this->connection) {
818 $this->error = "NotConnected";
819 return -2;
820 }
821 if (!$this->bind) {
822 $this->error = "NotConnected";
823 return -3;
824 }
825
826 // Encode to LDAP page code
827 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
828
829 $result = @ldap_delete($this->connection, $dn);
830
831 if ($result) {
832 return 1;
833 }
834 return -1;
835 }
836
845 public function dumpContent($dn, $info)
846 {
847 $content = '';
848
849 // Create file content
850 if (preg_match('/^ldap/', $this->server[0])) {
851 $target = "-H ".implode(',', $this->server);
852 } else {
853 $target = "-h ".implode(',', $this->server)." -p ".$this->serverPort;
854 }
855 $content .= "# ldapadd $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n";
856 $content .= "# ldapmodify $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n";
857 $content .= "# ldapdelete $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n";
858 if (in_array('localhost', $this->server)) {
859 $content .= "# If commands fails to connect, try without -h and -p\n";
860 }
861 $content .= "dn: ".$dn."\n";
862 foreach ($info as $key => $value) {
863 if (!is_array($value)) {
864 $content .= "$key: $value\n";
865 } else {
866 foreach ($value as $valuevalue) {
867 $content .= "$key: $valuevalue\n";
868 }
869 }
870 }
871 return $content;
872 }
873
881 public function dump($dn, $info)
882 {
883 global $conf;
884 $ldapDirTemp = $conf->ldap->dir_temp;
885 // Create content
886 $content = $this->dumpContent($dn, $info);
887
888 //Create directory & file
889 $result = dol_mkdir($ldapDirTemp);
890 if ($result != 0) {
891 $outputfile = $ldapDirTemp.'/ldapinput.in';
892 $fp = fopen($outputfile, "w");
893 if ($fp) {
894 fwrite($fp, $content);
895 fclose($fp);
896 dolChmod($outputfile);
897 return 1;
898 } else {
899 return -1;
900 }
901 } else {
902 return -1;
903 }
904 }
905
914 public function serverPing($host, $port = 389, $timeout = 1)
915 {
916 $regs = array();
917 if (preg_match('/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs)) {
918 // Replace ldaps:// by ssl://
919 $host = 'ssl://'.$regs[1];
920 } elseif (preg_match('/^ldap:\/\/([^\/]+)\/?$/', $host, $regs)) {
921 // Remove ldap://
922 $host = $regs[1];
923 }
924
925 //var_dump($newhostforstream); var_dump($host); var_dump($port);
926 //$host = 'ssl://ldap.test.local:636';
927 //$port = 636;
928
929 $errno = $errstr = 0;
930 /*
931 if ($methodtochecktcpconnect == 'socket') {
932 Try to use socket_create() method.
933 Method that use stream_context_create() works only on registered listed in stream stream_get_wrappers(): http, https, ftp, ...
934 }
935 */
936
937 // Use the method fsockopen to test tcp connect. No way to ignore ssl certificate errors with this method !
938 $op = @fsockopen($host, $port, $errno, $errstr, $timeout);
939
940 //var_dump($op);
941 if (!$op) {
942 return false; //DC is N/A
943 } else {
944 fclose($op); //explicitly close open socket connection
945 return true; //DC is up & running, we can safely connect with ldap_connect
946 }
947 }
948
949
950 // Attribute methods -----------------------------------------------------
951
961 public function addAttribute($dn, $info, $user)
962 {
963 dol_syslog(get_class($this)."::addAttribute dn=".$dn." info=".implode(',', $info));
964
965 // Check parameters
966 if (!$this->connection) {
967 $this->error = "NotConnected";
968 return -2;
969 }
970 if (!$this->bind) {
971 $this->error = "NotConnected";
972 return -3;
973 }
974
975 // Encode to LDAP page code
976 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
977 foreach ($info as $key => $val) {
978 if (!is_array($val)) {
979 $info[$key] = $this->convFromOutputCharset($val, $this->ldapcharset);
980 }
981 }
982
983 $this->dump($dn, $info);
984
985 //print_r($info);
986 $result = @ldap_mod_add($this->connection, $dn, $info);
987
988 if ($result) {
989 dol_syslog(get_class($this)."::add_attribute successful", LOG_DEBUG);
990 return 1;
991 } else {
992 $this->error = @ldap_error($this->connection);
993 dol_syslog(get_class($this)."::add_attribute failed: ".$this->error, LOG_ERR);
994 return -1;
995 }
996 }
997
1007 public function updateAttribute($dn, $info, $user)
1008 {
1009 dol_syslog(get_class($this)."::updateAttribute dn=".$dn." info=".implode(',', $info));
1010
1011 // Check parameters
1012 if (!$this->connection) {
1013 $this->error = "NotConnected";
1014 return -2;
1015 }
1016 if (!$this->bind) {
1017 $this->error = "NotConnected";
1018 return -3;
1019 }
1020
1021 // Encode to LDAP page code
1022 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
1023 foreach ($info as $key => $val) {
1024 if (!is_array($val)) {
1025 $info[$key] = $this->convFromOutputCharset($val, $this->ldapcharset);
1026 }
1027 }
1028
1029 $this->dump($dn, $info);
1030
1031 //print_r($info);
1032 $result = @ldap_mod_replace($this->connection, $dn, $info);
1033
1034 if ($result) {
1035 dol_syslog(get_class($this)."::updateAttribute successful", LOG_DEBUG);
1036 return 1;
1037 } else {
1038 $this->error = @ldap_error($this->connection);
1039 dol_syslog(get_class($this)."::updateAttribute failed: ".$this->error, LOG_ERR);
1040 return -1;
1041 }
1042 }
1043
1053 public function deleteAttribute($dn, $info, $user)
1054 {
1055 dol_syslog(get_class($this)."::deleteAttribute dn=".$dn." info=".implode(',', $info));
1056
1057 // Check parameters
1058 if (!$this->connection) {
1059 $this->error = "NotConnected";
1060 return -2;
1061 }
1062 if (!$this->bind) {
1063 $this->error = "NotConnected";
1064 return -3;
1065 }
1066
1067 // Encode to LDAP page code
1068 $dn = $this->convFromOutputCharset($dn, $this->ldapcharset);
1069 foreach ($info as $key => $val) {
1070 if (!is_array($val)) {
1071 $info[$key] = $this->convFromOutputCharset($val, $this->ldapcharset);
1072 }
1073 }
1074
1075 $this->dump($dn, $info);
1076
1077 //print_r($info);
1078 $result = @ldap_mod_del($this->connection, $dn, $info);
1079
1080 if ($result) {
1081 dol_syslog(get_class($this)."::deleteAttribute successful", LOG_DEBUG);
1082 return 1;
1083 } else {
1084 $this->error = @ldap_error($this->connection);
1085 dol_syslog(get_class($this)."::deleteAttribute failed: ".$this->error, LOG_ERR);
1086 return -1;
1087 }
1088 }
1089
1099 public function getAttribute($dn, $filter)
1100 {
1101 // Check parameters
1102 if (!$this->connection) {
1103 $this->error = "NotConnected";
1104 return -2;
1105 }
1106 if (!$this->bind) {
1107 $this->error = "NotConnected";
1108 return -3;
1109 }
1110
1111 $search = @ldap_search($this->connection, $dn, $filter);
1112
1113 // Only one entry should ever be returned
1114 $entry = @ldap_first_entry($this->connection, $search);
1115
1116 if (!$entry) {
1117 $this->ldapErrorCode = -1;
1118 $this->ldapErrorText = "Couldn't find entry";
1119 return 0; // Couldn't find entry...
1120 }
1121
1122 // Get values
1123 if (!($values = ldap_get_attributes($this->connection, $entry))) {
1124 $this->ldapErrorCode = ldap_errno($this->connection);
1125 $this->ldapErrorText = ldap_error($this->connection);
1126 return 0; // No matching attributes
1127 }
1128
1129 // Return an array containing the attributes.
1130 return $values;
1131 }
1132
1140 public function getAttributeValues($filterrecord, $attribute)
1141 {
1142 $attributes = array();
1143 $attributes[0] = $attribute;
1144
1145 // We need to search for this user in order to get their entry.
1146 $this->result = @ldap_search($this->connection, $this->people, $filterrecord, $attributes);
1147
1148 // Pourquoi cette ligne ?
1149 //$info = ldap_get_entries($this->connection, $this->result);
1150
1151 // Only one entry should ever be returned (no user will have the same uid)
1152 $entry = ldap_first_entry($this->connection, $this->result);
1153
1154 if (!$entry) {
1155 $this->ldapErrorCode = -1;
1156 $this->ldapErrorText = "Couldn't find user";
1157 return false; // Couldn't find the user...
1158 }
1159
1160 // Get values
1161 if (!$values = @ldap_get_values_len($this->connection, $entry, $attribute)) {
1162 $this->ldapErrorCode = ldap_errno($this->connection);
1163 $this->ldapErrorText = ldap_error($this->connection);
1164 return false; // No matching attributes
1165 }
1166
1167 // Return an array containing the attributes.
1168 return $values;
1169 }
1170
1183 public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array())
1184 {
1185 $fulllist = array();
1186
1187 dol_syslog(get_class($this)."::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".implode(',', $attributeArray).") activefilter=".$activefilter);
1188
1189 // if the directory is AD, then bind first with the search user first
1190 if ($this->serverType == "activedirectory") {
1191 $this->bindauth($this->searchUser, $this->searchPassword);
1192 dol_syslog(get_class($this)."::bindauth serverType=activedirectory searchUser=".$this->searchUser);
1193 }
1194
1195 // Define filter
1196 if (!empty($activefilter)) { // Use a predefined trusted filter (defined into setup by admin).
1197 if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) {
1198 $filter = '('.$this->filter.')';
1199 } elseif (((string) $activefilter == 'group') && $this->filtergroup) {
1200 $filter = '('.$this->filtergroup.')';
1201 } elseif (((string) $activefilter == 'member') && $this->filter) {
1202 $filter = '('.$this->filtermember.')';
1203 } else {
1204 // If this->filter/this->filtergroup is empty, make filter on * (all)
1205 $filter = '('.ldap_escape($useridentifier, '', LDAP_ESCAPE_FILTER).'=*)';
1206 }
1207 } else { // Use a filter forged using the $search value
1208 $filter = '('.ldap_escape($useridentifier, '', LDAP_ESCAPE_FILTER).'='.ldap_escape($search, '', LDAP_ESCAPE_FILTER).')';
1209 }
1210
1211 if (is_array($attributeArray)) {
1212 // Return list with required fields
1213 $attributeArray = array_values($attributeArray); // This is to force to have index reordered from 0 (not make ldap_search fails)
1214 dol_syslog(get_class($this)."::getRecords connection=".$this->connectedServer.":".$this->serverPort." userDn=".$userDn." filter=".$filter." attributeArray=(".implode(',', $attributeArray).")");
1215 //var_dump($attributeArray);
1216 $this->result = @ldap_search($this->connection, $userDn, $filter, $attributeArray);
1217 } else {
1218 // Return list with fields selected by default
1219 dol_syslog(get_class($this)."::getRecords connection=".$this->connectedServer.":".$this->serverPort." userDn=".$userDn." filter=".$filter);
1220 $this->result = @ldap_search($this->connection, $userDn, $filter);
1221 }
1222 if (!$this->result) {
1223 $this->error = 'LDAP search failed: '.ldap_errno($this->connection)." ".ldap_error($this->connection);
1224 return -1;
1225 }
1226
1227 $info = @ldap_get_entries($this->connection, $this->result);
1228
1229 // Warning: Dans info, les noms d'attributs sont en minuscule meme si passe
1230 // a ldap_search en majuscule !!!
1231 //print_r($info);
1232
1233 for ($i = 0; $i < $info["count"]; $i++) {
1234 $recordid = $this->convToOutputCharset($info[$i][strtolower($useridentifier)][0], $this->ldapcharset);
1235 if ($recordid) {
1236 //print "Found record with key $useridentifier=".$recordid."<br>\n";
1237 $fulllist[$recordid][$useridentifier] = $recordid;
1238
1239 // Add to the array for each attribute in my list
1240 $num = count($attributeArray);
1241 for ($j = 0; $j < $num; $j++) {
1242 $keyattributelower = strtolower($attributeArray[$j]);
1243 //print " Param ".$attributeArray[$j]."=".$info[$i][$keyattributelower][0]."<br>\n";
1244
1245 //permet de recuperer le SID avec Active Directory
1246 if ($this->serverType == "activedirectory" && $keyattributelower == "objectsid") {
1247 $objectsid = $this->getObjectSid($recordid);
1248 $fulllist[$recordid][$attributeArray[$j]] = $objectsid;
1249 } else {
1250 if (in_array($attributeArray[$j], $attributeAsArray) && is_array($info[$i][$keyattributelower])) {
1251 $valueTab = array();
1252 foreach ($info[$i][$keyattributelower] as $key => $value) {
1253 $valueTab[$key] = $this->convToOutputCharset($value, $this->ldapcharset);
1254 }
1255 $fulllist[$recordid][$attributeArray[$j]] = $valueTab;
1256 } else {
1257 $fulllist[$recordid][$attributeArray[$j]] = $this->convToOutputCharset($info[$i][$keyattributelower][0], $this->ldapcharset);
1258 }
1259 }
1260 }
1261 }
1262 }
1263
1264 asort($fulllist);
1265 return $fulllist;
1266 }
1267
1275 public function littleEndian($hex)
1276 {
1277 $result = '';
1278 for ($x = dol_strlen($hex) - 2; $x >= 0; $x -= 2) {
1279 $result .= substr($hex, $x, 2);
1280 }
1281 return $result;
1282 }
1283
1284
1292 public function getObjectSid($ldapUser)
1293 {
1294 $criteria = '('.$this->getUserIdentifier().'='.$ldapUser.')';
1295 $justthese = array("objectsid");
1296
1297 // if the directory is AD, then bind first with the search user first
1298 if ($this->serverType == "activedirectory") {
1299 $this->bindauth($this->searchUser, $this->searchPassword);
1300 }
1301
1302 $i = 0;
1303 $entry = null;
1304 $searchDN = $this->people;
1305
1306 while ($i <= 2) {
1307 $ldapSearchResult = @ldap_search($this->connection, $searchDN, $criteria, $justthese);
1308
1309 if (!$ldapSearchResult) {
1310 $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
1311 return -1;
1312 }
1313
1314 $entry = ldap_first_entry($this->connection, $ldapSearchResult);
1315
1316 if (!$entry) {
1317 // Si pas de resultat on cherche dans le domaine
1318 $searchDN = $this->domain;
1319 $i++;
1320 } else {
1321 $i++;
1322 $i++;
1323 }
1324 }
1325
1326 if ($entry) {
1327 $ldapBinary = ldap_get_values_len($this->connection, $entry, "objectsid");
1328 $SIDText = $this->binSIDtoText($ldapBinary[0]);
1329 return $SIDText;
1330 } else {
1331 $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
1332 return -1;
1333 }
1334 }
1335
1343 public function binSIDtoText($binsid)
1344 {
1345 $hex_sid = bin2hex($binsid);
1346 $rev = hexdec(substr($hex_sid, 0, 2)); // Get revision-part of SID
1347 $subcount = hexdec(substr($hex_sid, 2, 2)); // Get count of sub-auth entries
1348 $auth = hexdec(substr($hex_sid, 4, 12)); // SECURITY_NT_AUTHORITY
1349 $result = "$rev-$auth";
1350 for ($x = 0; $x < $subcount; $x++) {
1351 $result .= "-".hexdec($this->littleEndian(substr($hex_sid, 16 + ($x * 8), 8))); // get all SECURITY_NT_AUTHORITY
1352 }
1353 return $result;
1354 }
1355
1356
1370 public function search($checkDn, $filter)
1371 {
1372 dol_syslog(get_class($this)."::search checkDn=".$checkDn." filter=".$filter);
1373
1374 $checkDn = $this->convFromOutputCharset($checkDn, $this->ldapcharset);
1375 $filter = $this->convFromOutputCharset($filter, $this->ldapcharset);
1376
1377 // if the directory is AD, then bind first with the search user first
1378 if ($this->serverType == "activedirectory") {
1379 $this->bindauth($this->searchUser, $this->searchPassword);
1380 }
1381
1382 $this->result = @ldap_search($this->connection, $checkDn, $filter);
1383
1384 $result = @ldap_get_entries($this->connection, $this->result);
1385 if (!$result) {
1386 $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
1387 return -1;
1388 } else {
1389 ldap_free_result($this->result);
1390 return $result;
1391 }
1392 }
1393
1394
1403 public function fetch($user, $filter)
1404 {
1405 // Perform the search and get the entry handles
1406
1407 // if the directory is AD, then bind first with the search user first
1408 if ($this->serverType == "activedirectory") {
1409 $this->bindauth($this->searchUser, $this->searchPassword);
1410 }
1411
1412 $searchDN = $this->people; // TODO Why searching in people then domain ?
1413
1414 $result = '';
1415 $i = 0;
1416 while ($i <= 2) {
1417 dol_syslog(get_class($this)."::fetch search with searchDN=".$searchDN." filter=".$filter);
1418 $this->result = @ldap_search($this->connection, $searchDN, $filter);
1419 if ($this->result) {
1420 $result = @ldap_get_entries($this->connection, $this->result);
1421 if ($result['count'] > 0) {
1422 dol_syslog('Ldap::fetch search found '.$result['count'].' records');
1423 } else {
1424 dol_syslog('Ldap::fetch search returns but found no records');
1425 }
1426 //var_dump($result);exit;
1427 } else {
1428 $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
1429 dol_syslog(get_class($this)."::fetch search fails");
1430 return -1;
1431 }
1432
1433 if (!$result) {
1434 // Si pas de resultat on cherche dans le domaine
1435 $searchDN = $this->domain;
1436 $i++;
1437 } else {
1438 break;
1439 }
1440 }
1441
1442 if (!$result) {
1443 $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
1444 return -1;
1445 } else {
1446 $this->name = $this->convToOutputCharset($result[0][$this->attr_name][0], $this->ldapcharset);
1447 $this->firstname = $this->convToOutputCharset($result[0][$this->attr_firstname][0], $this->ldapcharset);
1448 $this->login = $this->convToOutputCharset($result[0][$this->attr_login][0], $this->ldapcharset);
1449 $this->phone = $this->convToOutputCharset($result[0][$this->attr_phone][0], $this->ldapcharset);
1450 $this->fax = $this->convToOutputCharset($result[0][$this->attr_fax][0], $this->ldapcharset);
1451 $this->mail = $this->convToOutputCharset($result[0][$this->attr_mail][0], $this->ldapcharset);
1452 $this->mobile = $this->convToOutputCharset($result[0][$this->attr_mobile][0], $this->ldapcharset);
1453
1454 $this->uacf = $this->parseUACF($this->convToOutputCharset($result[0]["useraccountcontrol"][0], $this->ldapcharset));
1455 if (isset($result[0]["pwdlastset"][0])) { // If expiration on password exists
1456 $this->pwdlastset = ($result[0]["pwdlastset"][0] != 0) ? $this->convertTime($this->convToOutputCharset($result[0]["pwdlastset"][0], $this->ldapcharset)) : 0;
1457 } else {
1458 $this->pwdlastset = -1;
1459 }
1460 if (!$this->name && !$this->login) {
1461 $this->pwdlastset = -1;
1462 }
1463 $this->badpwdtime = $this->convertTime($this->convToOutputCharset($result[0]["badpasswordtime"][0], $this->ldapcharset));
1464
1465 // FQDN domain
1466 $domain = str_replace('dc=', '', $this->domain);
1467 $domain = str_replace(',', '.', $domain);
1468 $this->domainFQDN = $domain;
1469
1470 // Set ldapUserDn (each user can have a different dn)
1471 //var_dump($result[0]);exit;
1472 $this->ldapUserDN = $result[0]['dn'];
1473
1474 ldap_free_result($this->result);
1475 return 1;
1476 }
1477 }
1478
1479
1480 // helper methods
1481
1487 public function getUserIdentifier()
1488 {
1489 if ($this->serverType == "activedirectory") {
1490 return $this->attr_sambalogin;
1491 } else {
1492 return $this->attr_login;
1493 }
1494 }
1495
1502 public function parseUACF($uacf)
1503 {
1504 //All flags array
1505 $flags = array(
1506 "TRUSTED_TO_AUTH_FOR_DELEGATION" => 16777216,
1507 "PASSWORD_EXPIRED" => 8388608,
1508 "DONT_REQ_PREAUTH" => 4194304,
1509 "USE_DES_KEY_ONLY" => 2097152,
1510 "NOT_DELEGATED" => 1048576,
1511 "TRUSTED_FOR_DELEGATION" => 524288,
1512 "SMARTCARD_REQUIRED" => 262144,
1513 "MNS_LOGON_ACCOUNT" => 131072,
1514 "DONT_EXPIRE_PASSWORD" => 65536,
1515 "SERVER_TRUST_ACCOUNT" => 8192,
1516 "WORKSTATION_TRUST_ACCOUNT" => 4096,
1517 "INTERDOMAIN_TRUST_ACCOUNT" => 2048,
1518 "NORMAL_ACCOUNT" => 512,
1519 "TEMP_DUPLICATE_ACCOUNT" => 256,
1520 "ENCRYPTED_TEXT_PWD_ALLOWED" => 128,
1521 "PASSWD_CANT_CHANGE" => 64,
1522 "PASSWD_NOTREQD" => 32,
1523 "LOCKOUT" => 16,
1524 "HOMEDIR_REQUIRED" => 8,
1525 "ACCOUNTDISABLE" => 2,
1526 "SCRIPT" => 1
1527 );
1528
1529 //Parse flags to text
1530 $retval = array();
1531 //while (list($flag, $val) = each($flags)) {
1532 foreach ($flags as $flag => $val) {
1533 if ($uacf >= $val) {
1534 $uacf -= $val;
1535 $retval[$val] = $flag;
1536 }
1537 }
1538
1539 //Return human friendly flags
1540 return $retval;
1541 }
1542
1549 public function parseSAT($samtype)
1550 {
1551 $stypes = array(
1552 805306368 => "NORMAL_ACCOUNT",
1553 805306369 => "WORKSTATION_TRUST",
1554 805306370 => "INTERDOMAIN_TRUST",
1555 268435456 => "SECURITY_GLOBAL_GROUP",
1556 268435457 => "DISTRIBUTION_GROUP",
1557 536870912 => "SECURITY_LOCAL_GROUP",
1558 536870913 => "DISTRIBUTION_LOCAL_GROUP"
1559 );
1560
1561 $retval = "";
1562 foreach ($stypes as $sat => $val) {
1563 if ($samtype == $sat) {
1564 $retval = $val;
1565 break;
1566 }
1567 }
1568 if (empty($retval)) {
1569 $retval = "UNKNOWN_TYPE_".$samtype;
1570 }
1571
1572 return $retval;
1573 }
1574
1581 public function convertTime($value)
1582 {
1583 $dateLargeInt = $value; // nano secondes depuis 1601 !!!!
1584 if (PHP_INT_SIZE < 8) {
1585 // 32 bit platform
1586 $secsAfterADEpoch = (float) $dateLargeInt / (10000000.); // secondes depuis le 1 jan 1601
1587 } else {
1588 // At least 64 bit platform
1589 $secsAfterADEpoch = (int) $dateLargeInt / (10000000); // secondes depuis le 1 jan 1601
1590 }
1591 $ADToUnixConvertor = ((1970 - 1601) * 365.242190) * 86400; // UNIX start date - AD start date * jours * secondes
1592 $unixTimeStamp = intval($secsAfterADEpoch - $ADToUnixConvertor); // Unix time stamp
1593 return $unixTimeStamp;
1594 }
1595
1596
1604 private function convToOutputCharset($str, $pagecodefrom = 'UTF-8')
1605 {
1606 global $conf;
1607 if ($pagecodefrom == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') {
1608 $str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
1609 }
1610 if ($pagecodefrom == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') {
1611 $str = mb_convert_encoding($str, 'ISO-8859-1');
1612 }
1613 return $str;
1614 }
1615
1623 public function convFromOutputCharset($str, $pagecodeto = 'UTF-8')
1624 {
1625 global $conf;
1626 if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') {
1627 $str = mb_convert_encoding($str, 'ISO-8859-1');
1628 }
1629 if ($pagecodeto == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') {
1630 $str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
1631 }
1632 return $str;
1633 }
1634
1635
1642 public function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS')
1643 {
1644
1645 if (empty($keygroup)) {
1646 $keygroup = 'LDAP_KEY_GROUPS';
1647 }
1648
1649 $search = '(' . getDolGlobalString($keygroup).'=*)';
1650 $result = $this->search($this->groups, $search);
1651 if ($result) {
1652 $c = $result['count'];
1653 $gids = array();
1654 for ($i = 0; $i < $c; $i++) {
1655 $gids[] = $result[$i]['gidnumber'][0];
1656 }
1657 rsort($gids);
1658
1659 return $gids[0] + 1;
1660 }
1661
1662 return 0;
1663 }
1664}
$c
Definition line.php:327
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 a 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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:153