29if (!defined(
'NOSESSION')) {
30 define(
'NOSESSION',
'1');
33$sapi_type = php_sapi_name();
34$script_file = basename(__FILE__);
38if (substr($sapi_type, 0, 3) ==
'cgi') {
39 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
43require_once $path.
"../../htdocs/master.inc.php";
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/functionscli.lib.php';
45require_once DOL_DOCUMENT_ROOT.
"/contact/class/contact.class.php";
46require_once DOL_DOCUMENT_ROOT.
"/user/class/user.class.php";
47require_once DOL_DOCUMENT_ROOT.
"/core/class/ldap.class.php";
58$version = DOL_VERSION;
62$hookmanager->initHooks(array(
'cli'));
70print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
71dol_syslog($script_file.
" launched with arg ".implode(
',', $argv));
73if (!isset($argv[1]) || !$argv[1]) {
74 print
"Usage: $script_file now [-y]\n";
78foreach ($argv as $key => $val) {
79 if (preg_match(
'/-y$/', $val, $reg)) {
86if (!empty($dolibarr_main_db_readonly)) {
87 print
"Error: instance in read-only mode\n";
91print
"Mails sending disabled (useless in batch mode)\n";
92$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
94print
"----- Synchronize all records from Dolibarr database:\n";
95print
"type=".$conf->db->type.
"\n";
96print
"host=".$conf->db->host.
"\n";
97print
"port=".$conf->db->port.
"\n";
98print
"login=".$conf->db->user.
"\n";
100print
"database=".$conf->db->name.
"\n";
102print
"----- To LDAP database:\n";
111 print
"Press a key to confirm...\n";
112 $input = trim(fgets(STDIN));
113 print
"Warning, this operation may result in data loss if it failed.\n";
114 print
"Be sure to have a backup of your LDAP database (With OpenLDAP: slapcat > save.ldif).\n";
115 print
"Hit Enter to continue or CTRL+C to stop...\n";
116 $input = trim(fgets(STDIN));
126$sql =
"SELECT rowid";
127$sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople";
129$resql = $db->query($sql);
131 $num = $db->num_rows($resql);
135 $ldap->connectBind();
140 $obj = $db->fetch_object($resql);
143 $contact->id = $obj->rowid;
144 $contact->fetch($contact->id);
146 print $langs->trans(
"UpdateContact").
" rowid=".$contact->id.
" ".$contact->getFullName($langs);
148 $oldobject = $contact;
150 $oldinfo = $oldobject->_load_ldap_info();
151 $olddn = $oldobject->_load_ldap_dn($oldinfo);
153 $info = $contact->_load_ldap_info();
154 $dn = $contact->_load_ldap_dn($info);
156 $result = $ldap->add($dn, $info, $user);
157 $result = $ldap->update($dn, $info, $user, $olddn);
159 print
" - ".$langs->trans(
"OK");
162 print
" - ".$langs->trans(
"KO").
' - '.$ldap->error;
Class to manage LDAP features.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...