29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
35 $langs->load(
"admin");
40 $action =
GETPOST(
'action',
'aZ09');
43 $hookmanager->initHooks(array(
'adminldap',
'globaladmin'));
49 $parameters = array();
50 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
51 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
55 if ($action ==
'setvalue' && $user->admin)
62 if (!
dolibarr_set_const($db,
'LDAP_SERVER_PROTOCOLVERSION',
GETPOST(
"LDAP_SERVER_PROTOCOLVERSION",
'aZ09'),
'chaine', 0,
'', $conf->entity)) $error++;
63 if (!
dolibarr_set_const($db,
'LDAP_SERVER_HOST',
GETPOST(
"host",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
64 if (!
dolibarr_set_const($db,
'LDAP_SERVER_HOST_SLAVE',
GETPOST(
"slave",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
70 if (!
dolibarr_set_const($db,
'LDAP_SYNCHRO_ACTIVE',
GETPOST(
"activesynchro",
'aZ09'),
'chaine', 0,
'', $conf->entity)) $error++;
71 if (!
dolibarr_set_const($db,
'LDAP_CONTACT_ACTIVE',
GETPOST(
"activecontact",
'aZ09'),
'chaine', 0,
'', $conf->entity)) $error++;
72 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_ACTIVE',
GETPOST(
"activemembers",
'aZ09'),
'chaine', 0,
'', $conf->entity)) $error++;
73 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_TYPE_ACTIVE',
GETPOST(
"activememberstypes",
'aZ09'),
'chaine', 0,
'', $conf->entity)) $error++;
90 llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
92 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
99 if (!function_exists(
"ldap_connect"))
101 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"), null,
'errors');
105 $form =
new Form($db);
108 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue">';
109 print '<input type="hidden" name="token" value="'.newToken().
'">';
113 print '<table class="noborder centpercent">';
116 print
'<tr class="liste_titre">';
117 print
'<td colspan="3">'.$langs->trans(
"LDAPSynchronization").
'</td>';
122 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnSynchroActive").
'</td><td>';
123 $arraylist = array();
124 $arraylist[
'0'] = $langs->trans(
"No");
125 $arraylist[
'ldap2dolibarr'] = $langs->trans(
"LDAPToDolibarr");
126 $arraylist[
'dolibarr2ldap'] = $langs->trans(
"DolibarrToLDAP");
127 print $form->selectarray(
'activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE);
128 print
'</td><td>'.$langs->trans(
"LDAPDnSynchroActiveExample");
129 if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN)
131 print
'<br><font class="error">'.$langs->trans(
"LDAPSetupNotComplete").
'</font>';
136 if (!empty($conf->societe->enabled))
138 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnContactActive").
'</td><td>';
139 $arraylist = array();
140 $arraylist[
'0'] = $langs->trans(
"No");
141 $arraylist[
'1'] = $langs->trans(
"DolibarrToLDAP");
142 print $form->selectarray(
'activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE);
143 print
'</td><td>'.$langs->trans(
"LDAPDnContactActiveExample").
'</td></tr>';
147 if (!empty($conf->adherent->enabled))
149 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnMemberActive").
'</td><td>';
150 $arraylist = array();
151 $arraylist[
'0'] = $langs->trans(
"No");
152 $arraylist[
'1'] = $langs->trans(
"DolibarrToLDAP");
153 $arraylist[
'ldap2dolibarr'] = $langs->trans(
"LDAPToDolibarr").
' ('.$langs->trans(
"SupportedForLDAPImportScriptOnly").
')';
154 print $form->selectarray(
'activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE);
155 print
'</td><td>'.$langs->trans(
"LDAPDnMemberActiveExample").
'</td></tr>';
159 if (!empty($conf->adherent->enabled))
161 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnMemberTypeActive").
'</td><td>';
162 $arraylist = array();
163 $arraylist[
'0'] = $langs->trans(
"No");
164 $arraylist[
'1'] = $langs->trans(
"DolibarrToLDAP");
165 $arraylist[
'ldap2dolibarr'] = $langs->trans(
"LDAPToDolibarr").
' ('.$langs->trans(
"SupportedForLDAPImportScriptOnly").
')';
166 print $form->selectarray(
'activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE);
167 print
'</td><td>'.$langs->trans(
"LDAPDnMemberTypeActiveExample").
'</td></tr>';
171 $parameters = array();
172 $reshook = $hookmanager->executeHooks(
'addAdminLdapOptions', $parameters);
173 print $hookmanager->resPrint;
175 print
'<tr class="liste_titre">';
176 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
177 print
'<td>'.$langs->trans(
"Value").
'</td>';
178 print
'<td>'.$langs->trans(
"Example").
'</td>';
182 print
'<tr class="oddeven"><td>'.$langs->trans(
"Type").
'</td><td>';
183 $arraylist = array();
184 $arraylist[
'activedirectory'] =
'Active Directory';
185 $arraylist[
'openldap'] =
'OpenLdap';
186 $arraylist[
'egroupware'] =
'Egroupware';
187 print $form->selectarray(
'type', $arraylist, $conf->global->LDAP_SERVER_TYPE);
188 print
'</td><td> </td></tr>';
191 print
'<tr class="oddeven"><td>'.$langs->trans(
"Version").
'</td><td>';
192 $arraylist = array();
193 $arraylist[
'3'] =
'Version 3';
194 $arraylist[
'2'] =
'Version 2';
195 print $form->selectarray(
'LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION);
196 print
'</td><td>'.$langs->trans(
"LDAPServerProtocolVersion").
'</td></tr>';
199 print
'<tr class="oddeven"><td>';
200 print $langs->trans(
"LDAPPrimaryServer").
'</td><td>';
201 print
'<input size="25" type="text" name="host" value="'.$conf->global->LDAP_SERVER_HOST.
'">';
202 print
'</td><td>'.$langs->trans(
"LDAPServerExample").
'</td></tr>';
205 print
'<tr class="oddeven"><td>';
206 print $langs->trans(
"LDAPSecondaryServer").
'</td><td>';
207 print
'<input size="25" type="text" name="slave" value="'.$conf->global->LDAP_SERVER_HOST_SLAVE.
'">';
208 print
'</td><td>'.$langs->trans(
"LDAPServerExample").
'</td></tr>';
211 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerPort").
'</td><td>';
212 if (!empty($conf->global->LDAP_SERVER_PORT))
214 print
'<input size="25" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.
'">';
216 print
'<input size="25" type="text" name="port" value="389">';
218 print
'</td><td>'.$langs->trans(
"LDAPServerPortExample").
'</td></tr>';
221 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerDn").
'</td><td>';
222 print
'<input size="25" type="text" name="dn" value="'.$conf->global->LDAP_SERVER_DN.
'">';
223 print
'</td><td>'.$langs->trans(
"LDAPServerDnExample").
'</td></tr>';
226 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerUseTLS").
'</td><td>';
227 $arraylist = array();
228 $arraylist[
'0'] = $langs->trans(
"No");
229 $arraylist[
'1'] = $langs->trans(
"Yes");
230 print $form->selectarray(
'usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS);
231 print
'</td><td>'.$langs->trans(
"LDAPServerUseTLSExample").
'</td></tr>';
233 print
'<tr class="liste_titre">';
234 print
'<td colspan="3">'.$langs->trans(
"ForANonAnonymousAccess").
'</td>';
238 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPAdminDn").
'</td><td>';
239 print
'<input size="25" type="text" name="admin" value="'.$conf->global->LDAP_ADMIN_DN.
'">';
240 print
'</td><td>'.$langs->trans(
"LDAPAdminDnExample").
'</td></tr>';
243 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPPassword").
'</td><td>';
244 if (!empty($conf->global->LDAP_ADMIN_PASS))
246 print
'<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.
'">';
248 print
'<input size="25" type="text" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.
'">';
250 print
'</td><td>'.$langs->trans(
'Password').
' (ex: secret)</td></tr>';
256 print
'<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'"></div>';
266 if (function_exists(
"ldap_connect"))
268 if (!empty($conf->global->LDAP_SERVER_HOST))
270 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test">'.$langs->trans(
"LDAPTestConnect").
'</a><br><br>';
273 if ($_GET[
"action"] ==
'test')
277 $result = $ldap->connect_bind();
282 print
'<font class="ok">'.$langs->trans(
"LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).
'</font>';
285 if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS))
290 print
'<font class="ok">'.$langs->trans(
"LDAPBindOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace(
'/./i',
'*', $conf->global->LDAP_ADMIN_PASS)).
'</font>';
294 print
'<font class="error">'.$langs->trans(
"LDAPBindKO", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace(
'/./i',
'*', $conf->global->LDAP_ADMIN_PASS)).
'</font>';
296 print $langs->trans(
"Error").
' '.$ldap->error;
301 print
'<font class="warning">'.$langs->trans(
"LDAPNoUserOrPasswordProvidedAccessIsReadOnly").
'</font>';
307 if (($ldap->getVersion() == 3))
310 print
'<font class="ok">'.$langs->trans(
"LDAPSetupForVersion3").
'</font>';
314 print
'<font class="ok">'.$langs->trans(
"LDAPSetupForVersion2").
'</font>';
318 $unbind = $ldap->unbind();
321 print
'<font class="error">'.$langs->trans(
"LDAPTCPConnectKO", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).
'</font>';
323 print $langs->trans(
"Error").
' '.$ldap->error;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class to manage LDAP features.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
ldap_prepare_head()
Initialize the array of tabs for customer invoice.