32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
40$langs->loadLangs(array(
'admin',
'errors'));
46$action =
GETPOST(
'action',
'aZ09');
52if ($action ==
'setvalue' && $user->admin) {
77 if (!
dolibarr_set_const($db,
'LDAP_FIELD_PASSWORD_CRYPTED',
GETPOST(
"fieldpasswordcrypted"),
'chaine', 0,
'', $conf->entity)) {
128 if (!
dolibarr_set_const($db,
'LDAP_FIELD_HOMEDIRECTORY',
GETPOST(
"fieldhomedirectory"),
'chaine', 0,
'', $conf->entity)) {
131 if (!
dolibarr_set_const($db,
'LDAP_FIELD_HOMEDIRECTORYPREFIX',
GETPOST(
"fieldhomedirectoryprefix"),
'chaine', 0,
'', $conf->entity)) {
141 if (!
dolibarr_set_const($db,
'LDAP_KEY_USERS', $valkey,
'chaine', 0,
'', $conf->entity)) {
160$form =
new Form($db);
162llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP',
'', 0, 0,
'',
'',
'',
'mod-admin page-ldap_users');
163$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
165print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
170if (!function_exists(
"ldap_connect")) {
171 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
175print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
176print
'<input type="hidden" name="token" value="'.newToken().
'">';
181print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescUsers").
'</span><br>';
185print
'<table class="noborder centpercent">';
187print
'<tr class="liste_titre">';
188print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeUsers").
'</td>';
192print
'<!-- LDAP_USER_DN -->';
193print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPUserDn").
'</span></td><td>';
194print
'<input size="48" type="text" name="user" value="'.getDolGlobalString(
'LDAP_USER_DN').
'">';
195print
'</td><td>'.$langs->trans(
"LDAPUserDnExample").
'</td>';
196print
'<td> </td>';
200print
'<!-- LDAP_USER_OBJECT_CLASS -->';
201print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPUserObjectClassList").
'</span></td><td>';
202print
'<input size="48" type="text" name="objectclass" value="'.getDolGlobalString(
'LDAP_USER_OBJECT_CLASS').
'">';
203print
'</td><td>'.$langs->trans(
"LDAPUserObjectClassListExample").
'</td>';
204print
'<td> </td>';
208print
'<!-- LDAP_FILTER_CONNECTION -->';
209print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFilterConnection").
'</td><td>';
210print
'<input size="48" type="text" name="filterconnection" value="'.getDolGlobalString(
'LDAP_FILTER_CONNECTION').
'">';
211print
'</td><td>'.$langs->trans(
"LDAPFilterConnectionExample").
'</td>';
217print
'<table class="noborder centpercent">';
219print
'<tr class="liste_titre">';
220print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
221print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
222print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
226print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFullname").
'</td><td>';
227print
'<input size="25" type="text" name="fieldfullname" value="'.getDolGlobalString(
'LDAP_FIELD_FULLNAME').
'">';
228print
'</td><td>'.$langs->trans(
"LDAPFieldFullnameExample").
'</td>';
229print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FULLNAME"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_FULLNAME') ?
' checked' :
'').
"></td>";
233print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
234print
'<input size="25" type="text" name="fieldname" value="'.getDolGlobalString(
'LDAP_FIELD_NAME').
'">';
235print
'</td><td>'.$langs->trans(
"LDAPFieldNameExample").
'</td>';
236print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_NAME"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_NAME') ?
' checked' :
'').
"></td>";
240print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstName").
'</td><td>';
241print
'<input size="25" type="text" name="fieldfirstname" value="'.getDolGlobalString(
'LDAP_FIELD_FIRSTNAME').
'">';
242print
'</td><td>'.$langs->trans(
"LDAPFieldFirstNameExample").
'</td>';
243print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FIRSTNAME"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_FIRSTNAME') ?
' checked' :
'').
"></td>";
247print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldLoginUnix").
'</td><td>';
248print
'<input size="25" type="text" name="fieldlogin" value="'.getDolGlobalString(
'LDAP_FIELD_LOGIN').
'">';
249print
'</td><td>'.$langs->trans(
"LDAPFieldLoginExample").
'</td>';
250print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_LOGIN') ?
' checked' :
'').
"></td>";
254print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldLoginSamba").
'</td><td>';
255print
'<input size="25" type="text" name="fieldloginsamba" value="'.getDolGlobalString(
'LDAP_FIELD_LOGIN_SAMBA').
'">';
256print
'</td><td>'.$langs->trans(
"LDAPFieldLoginSambaExample").
'</td>';
257print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN_SAMBA"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_LOGIN_SAMBA') ?
' checked' :
'').
"></td>";
261print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPasswordNotCrypted").
'</td><td>';
262print
'<input size="25" type="text" name="fieldpassword" value="'.getDolGlobalString(
'LDAP_FIELD_PASSWORD').
'">';
263print
'</td><td>'.$langs->trans(
"LDAPFieldPasswordExample").
'</td>';
264print
'<td class="right"> </td>';
268print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPasswordCrypted").
'</td><td>';
269print
'<input size="25" type="text" name="fieldpasswordcrypted" value="'.getDolGlobalString(
'LDAP_FIELD_PASSWORD_CRYPTED').
'">';
270print
'</td><td>'.$langs->trans(
"LDAPFieldPasswordExample").
'</td>';
271print
'<td class="right"> </td>';
275print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMail").
'</td><td>';
276print
'<input size="25" type="text" name="fieldmail" value="'.getDolGlobalString(
'LDAP_FIELD_MAIL').
'">';
277print
'</td><td>'.$langs->trans(
"LDAPFieldMailExample").
'</td>';
278print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_MAIL"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_MAIL') ?
' checked' :
'').
"></td>";
282print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPhone").
'</td><td>';
283print
'<input size="25" type="text" name="fieldphone" value="'.getDolGlobalString(
'LDAP_FIELD_PHONE').
'">';
284print
'</td><td>'.$langs->trans(
"LDAPFieldPhoneExample").
'</td>';
285print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_PHONE"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_PHONE') ?
' checked' :
'').
"></td>";
289print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMobile").
'</td><td>';
290print
'<input size="25" type="text" name="fieldmobile" value="'.getDolGlobalString(
'LDAP_FIELD_MOBILE').
'">';
291print
'</td><td>'.$langs->trans(
"LDAPFieldMobileExample").
'</td>';
292print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_MOBILE"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_MOBILE') ?
' checked' :
'').
"></td>";
296print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFax").
'</td><td>';
297print
'<input size="25" type="text" name="fieldfax" value="'.getDolGlobalString(
'LDAP_FIELD_FAX').
'">';
298print
'</td><td>'.$langs->trans(
"LDAPFieldFaxExample").
'</td>';
299print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_FAX"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_FAX') ?
' checked' :
'').
"></td>";
303print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCompany").
'</td><td>';
304print
'<input size="25" type="text" name="fieldcompany" value="'.getDolGlobalString(
'LDAP_FIELD_COMPANY').
'">';
305print
'</td><td>'.$langs->trans(
"LDAPFieldCompanyExample").
'</td>';
306print
'<td class="right"> </td>';
310print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldAddress").
'</td><td>';
311print
'<input size="25" type="text" name="fieldaddress" value="'.getDolGlobalString(
'LDAP_FIELD_ADDRESS').
'">';
312print
'</td><td>'.$langs->trans(
"LDAPFieldAddressExample").
'</td>';
313print
'<td class="right"> </td>';
317print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldZip").
'</td><td>';
318print
'<input size="25" type="text" name="fieldzip" value="'.getDolGlobalString(
'LDAP_FIELD_ZIP').
'">';
319print
'</td><td>'.$langs->trans(
"LDAPFieldZipExample").
'</td>';
320print
'<td class="right"> </td>';
324print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTown").
'</td><td>';
325print
'<input size="25" type="text" name="fieldtown" value="'.getDolGlobalString(
'LDAP_FIELD_TOWN').
'">';
326print
'</td><td>'.$langs->trans(
"LDAPFieldTownExample").
'</td>';
327print
'<td class="right"> </td>';
331print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCountry").
'</td><td>';
332print
'<input size="25" type="text" name="fieldcountry" value="'.getDolGlobalString(
'LDAP_FIELD_COUNTRY').
'">';
333print
'</td><td> </td>';
334print
'<td class="right"> </td>';
338print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTitle").
'</td><td>';
339print
'<input size="25" type="text" name="fieldtitle" value="'.getDolGlobalString(
'LDAP_FIELD_TITLE').
'">';
340print
'</td><td>'.$langs->trans(
"LDAPFieldTitleExample").
'</td>';
341print
'<td class="right"> </td>';
345print
'<tr class="oddeven"><td>'.$langs->trans(
"Note").
'</td><td>';
346print
'<input size="25" type="text" name="fielddescription" value="'.getDolGlobalString(
'LDAP_FIELD_DESCRIPTION').
'">';
347print
'</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
348print
'<td class="right"> </td>';
352print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldSid").
'</td><td>';
353print
'<input size="25" type="text" name="fieldsid" value="'.getDolGlobalString(
'LDAP_FIELD_SID').
'">';
354print
'</td><td>'.$langs->trans(
"LDAPFieldSidExample").
'</td>';
355print
'<td class="right"><input type="radio" name="key" value="LDAP_FIELD_SID"'.(getDolGlobalString(
'LDAP_KEY_USERS') ==
getDolGlobalString(
'LDAP_FIELD_SID') ?
' checked' :
'').
"></td>";
359print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupid").
'</td><td>';
360print
'<input size="25" type="text" name="fieldgroupid" value="'.getDolGlobalString(
'LDAP_FIELD_GROUPID').
'">';
361print
'</td><td>'.$langs->trans(
"LDAPFieldGroupidExample").
'</td>';
362print
'<td class="right"> </td>';
366print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldUserid").
'</td><td>';
367print
'<input size="25" type="text" name="fielduserid" value="'.getDolGlobalString(
'LDAP_FIELD_USERID').
'">';
368print
'</td><td>'.$langs->trans(
"LDAPFieldUseridExample").
'</td>';
369print
'<td class="right"> </td>';
373print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomedirectory").
'</td><td>';
374print
'<input size="25" type="text" name="fieldhomedirectory" value="'.getDolGlobalString(
'LDAP_FIELD_HOMEDIRECTORY').
'">';
375print
'</td><td>'.$langs->trans(
"LDAPFieldHomedirectoryExample").
'</td>';
376print
'<td class="right"> </td>';
380print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomedirectoryprefix").
'</td><td>';
381print
'<input size="25" type="text" name="fieldhomedirectoryprefix" value="'.getDolGlobalString(
'LDAP_FIELD_HOMEDIRECTORYPREFIX').
'">';
382print
'</td><td></td>';
383print
'<td class="right"> </td>';
388print
info_admin($langs->trans(
"LDAPDescValues"));
392print $form->buttonsSaveCancel(
"Modify",
'');
401 $butlabel = $langs->trans(
"LDAPTestSynchroUser");
402 $testlabel =
'testuser';
408} elseif (
getDolGlobalString(
'LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
409 $butlabel = $langs->trans(
"LDAPTestSearch");
410 $testlabel =
'testsearchuser';
417if (function_exists(
"ldap_connect")) {
418 if ($action ==
'testuser') {
427 $result = $ldap->connectBind();
430 $info =
$object->_load_ldap_info();
431 $dn =
$object->_load_ldap_dn($info);
433 $result1 = $ldap->delete($dn);
434 $result2 = $ldap->add($dn, $info, $user);
435 $result3 = $ldap->delete($dn);
439 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
442 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
443 print
': '.$ldap->error;
445 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
449 print
"LDAP input file used for test:<br><br>\n";
450 print nl2br($ldap->dumpContent($dn, $info));
454 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
455 print
': '.$ldap->error;
457 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
461 if ($action ==
'testsearchuser') {
470 $result = $ldap->connectBind();
473 $required_fields = array(
493 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
500 if (is_array($ldapusers)) {
501 foreach ($ldapusers as $key => $ldapuser) {
504 foreach ($required_fields as $value) {
506 $label .= $value.
"=".$ldapuser[$value].
" ";
509 $liste[$key] = $label;
516 print
"LDAP search for user:<br>\n";
517 print
"search: *<br>\n";
518 print
"userDN: ".getDolGlobalString(
'LDAP_USER_DN').
"<br>\n";
519 print
"useridentifier: ".getDolGlobalString(
'LDAP_KEY_USERS').
"<br>\n";
520 print
"requested fields: ".implode(
',', $required_fields).
"<br>\n";
521 print
"=> ".count($liste).
" records<br>\n";
525 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
526 print
': '.$ldap->error;
528 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage LDAP features.
Class to manage Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
ldap_prepare_head()
Initialize the array of tabs for customer invoice.
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
Show button test LDAP synchro.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.