29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
37 $langs->loadLangs(array(
'admin',
'errors'));
42 $action =
GETPOST(
'action',
'aZ09');
48 if ($action ==
'setvalue' && $user->admin)
55 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_OBJECT_CLASS',
GETPOST(
"objectclass"),
'chaine', 0,
'', $conf->entity)) $error++;
56 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FILTER',
GETPOST(
"filterconnection"),
'chaine', 0,
'', $conf->entity)) $error++;
58 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_FULLNAME',
GETPOST(
"fieldfullname"),
'chaine', 0,
'', $conf->entity)) $error++;
60 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_LOGIN_SAMBA',
GETPOST(
"fieldloginsamba"),
'chaine', 0,
'', $conf->entity)) $error++;
61 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_PASSWORD',
GETPOST(
"fieldpassword"),
'chaine', 0,
'', $conf->entity)) $error++;
62 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED',
GETPOST(
"fieldpasswordcrypted"),
'chaine', 0,
'', $conf->entity)) $error++;
64 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_FIRSTNAME',
GETPOST(
"fieldfirstname"),
'chaine', 0,
'', $conf->entity)) $error++;
67 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_PHONE_PERSO',
GETPOST(
"fieldphoneperso"),
'chaine', 0,
'', $conf->entity)) $error++;
68 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_MOBILE',
GETPOST(
"fieldmobile"),
'chaine', 0,
'', $conf->entity)) $error++;
71 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_COMPANY',
GETPOST(
"fieldcompany"),
'chaine', 0,
'', $conf->entity)) $error++;
72 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_ADDRESS',
GETPOST(
"fieldaddress"),
'chaine', 0,
'', $conf->entity)) $error++;
75 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_COUNTRY',
GETPOST(
"fieldcountry"),
'chaine', 0,
'', $conf->entity)) $error++;
76 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_DESCRIPTION',
GETPOST(
"fielddescription"),
'chaine', 0,
'', $conf->entity)) $error++;
77 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_NOTE_PUBLIC',
GETPOST(
"fieldnotepublic"),
'chaine', 0,
'', $conf->entity)) $error++;
78 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_FIELD_BIRTHDATE',
GETPOST(
"fieldbirthdate"),
'chaine', 0,
'', $conf->entity)) $error++;
79 if (!
dolibarr_set_const($db,
'LDAP_FIELD_MEMBER_STATUS',
GETPOST(
"fieldstatus"),
'chaine', 0,
'', $conf->entity)) $error++;
80 if (!
dolibarr_set_const($db,
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION',
GETPOST(
"fieldendlastsubscription"),
'chaine', 0,
'', $conf->entity)) $error++;
83 if (!
dolibarr_set_const($db,
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE',
GETPOST(
"fieldfirstsubscriptiondate"),
'chaine', 0,
'', $conf->entity)) $error++;
84 if (!
dolibarr_set_const($db,
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT',
GETPOST(
"fieldfirstsubscriptionamount"),
'chaine', 0,
'', $conf->entity)) $error++;
85 if (!
dolibarr_set_const($db,
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE',
GETPOST(
"fieldlastsubscriptiondate"),
'chaine', 0,
'', $conf->entity)) $error++;
86 if (!
dolibarr_set_const($db,
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT',
GETPOST(
"fieldlastsubscriptionamount"),
'chaine', 0,
'', $conf->entity)) $error++;
91 if ($key) $valkey = $conf->global->$key;
92 if (!
dolibarr_set_const($db,
'LDAP_KEY_MEMBERS', $valkey,
'chaine', 0,
'', $conf->entity)) $error++;
110 $form =
new Form($db);
112 llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
113 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
120 if (!function_exists(
"ldap_connect"))
122 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"), null,
'errors');
125 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue">';
126 print '<input type="hidden" name="token" value="'.newToken().
'">';
131 print $langs->trans(
"LDAPDescMembers").
'<br>';
134 print '<table class="noborder centpercent">';
136 print '<tr class="liste_titre">';
137 print '<td colspan="4">'.$langs->trans(
"LDAPSynchronizeMembers").
'</td>';
141 print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans(
"LDAPMemberDn").
'</span></td><td>';
142 print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.
'">';
143 print '</td><td>'.$langs->trans(
"LDAPMemberDnExample").
'</td>';
144 print '<td> </td>';
148 print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans(
"LDAPMemberObjectClassList").
'</span></td><td>';
149 print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.
'">';
150 print '</td><td>'.$langs->trans(
"LDAPMemberObjectClassListExample").
'</td>';
151 print '<td> </td>';
155 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFilterConnection").
'</td><td>';
156 print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_MEMBER_FILTER.
'">';
157 print '</td><td>'.$langs->trans(
"LDAPFilterConnectionExample").
'</td>';
163 print '<table class="noborder centpercent">';
165 print '<tr class="liste_titre">';
166 print '<td width="25%">'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
167 print '<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
168 print '<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
174 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFullname").
'</td><td>';
175 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.
'">';
176 print '</td><td>'.$langs->trans(
"LDAPFieldFullnameExample").
'</td>';
177 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_FULLNAME) ?
' checked' :
'').
"></td>";
181 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
182 print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.
'">';
183 print '</td><td>'.$langs->trans(
"LDAPFieldNameExample").
'</td>';
184 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_NAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_NAME) ?
' checked' :
'').
"></td>";
188 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstName").
'</td><td>';
189 print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.
'">';
190 print '</td><td>'.$langs->trans(
"LDAPFieldFirstNameExample").
'</td>';
191 print '<td class="right"> </td>';
195 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldLoginUnix").
'</td><td>';
196 print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.
'">';
197 print '</td><td>'.$langs->trans(
"LDAPFieldLoginExample").
'</td>';
198 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN) ?
' checked' :
'').
"></td>";
202 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldLoginSamba").
'</td><td>';
203 print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.
'">';
204 print '</td><td>'.$langs->trans(
"LDAPFieldLoginSambaExample").
'</td>';
205 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA) ?
' checked' :
'').
"></td>";
209 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPasswordNotCrypted").
'</td><td>';
210 print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.
'">';
211 print '</td><td>'.$langs->trans(
"LDAPFieldPasswordExample").
'</td>';
212 print '<td class="right"> </td>';
216 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPasswordCrypted").
'</td><td>';
217 print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.
'">';
218 print '</td><td>'.$langs->trans(
"LDAPFieldPasswordExample").
'</td>';
219 print '<td class="right"> </td>';
223 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMail").
'</td><td>';
224 print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.
'">';
225 print '</td><td>'.$langs->trans(
"LDAPFieldMailExample").
'</td>';
226 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_MAIL"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_MAIL) ?
' checked' :
'').
"></td>";
230 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPhone").
'</td><td>';
231 print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.
'">';
232 print '</td><td>'.$langs->trans(
"LDAPFieldPhoneExample").
'</td>';
233 print '<td class="right"> </td>';
238 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomePhone").
'</td><td>';
239 print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.
'">';
240 print '</td><td>'.$langs->trans(
"LDAPFieldHomePhoneExample").
'</td>';
241 print '<td class="right"> </td>';
245 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMobile").
'</td><td>';
246 print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.
'">';
247 print '</td><td>'.$langs->trans(
"LDAPFieldMobileExample").
'</td>';
248 print '<td class="right"> </td>';
252 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldSkype").
'</td><td>';
253 print '<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_MEMBER_FIELD_SKYPE.
'">';
254 print '</td><td>'.$langs->trans(
"LDAPFieldSkypeExample").
'</td>';
255 print '<td class="right"> </td>';
259 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFax").
'</td><td>';
260 print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.
'">';
261 print '</td><td>'.$langs->trans(
"LDAPFieldFaxExample").
'</td>';
262 print '<td class="right"> </td>';
266 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCompany").
'</td><td>';
267 print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_MEMBER_FIELD_COMPANY.
'">';
268 print '</td><td>'.$langs->trans(
"LDAPFieldCompanyExample").
'</td>';
269 print '<td class="right"> </td>';
273 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldAddress").
'</td><td>';
274 print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.
'">';
275 print '</td><td>'.$langs->trans(
"LDAPFieldAddressExample").
'</td>';
276 print '<td class="right"> </td>';
280 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldZip").
'</td><td>';
281 print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.
'">';
282 print '</td><td>'.$langs->trans(
"LDAPFieldZipExample").
'</td>';
283 print '<td class="right"> </td>';
287 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTown").
'</td><td>';
288 print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.
'">';
289 print '</td><td>'.$langs->trans(
"LDAPFieldTownExample").
'</td>';
290 print '<td class="right"> </td>';
294 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCountry").
'</td><td>';
295 print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.
'">';
296 print '</td><td> </td>';
297 print '<td class="right"> </td>';
301 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldDescription").
'</td><td>';
302 print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.
'">';
303 print '</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
304 print '<td class="right"> </td>';
308 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldNotePublic").
'</td><td>';
309 print '<input size="25" type="text" name="fieldnotepublic" value="'.$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC.
'">';
310 print '</td><td>'.$langs->trans(
"LDAPFieldNotePublicExample").
'</td>';
311 print '<td class="right"> </td>';
316 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldBirthdate").
'</td><td>';
317 print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.
'">';
318 print '</td><td> </td>';
319 print '<td class="right"> </td>';
323 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldStatus").
'</td><td>';
324 print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.
'">';
325 print '</td><td> </td>';
326 print '<td class="right"> </td>';
331 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstSubscriptionDate").
'</td><td>';
332 print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.
'">';
333 print '</td><td> </td>';
334 print '<td class="right"> </td>';
338 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstSubscriptionAmount").
'</td><td>';
339 print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.
'">';
340 print '</td><td> </td>';
341 print '<td class="right"> </td>';
345 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldLastSubscriptionDate").
'</td><td>';
346 print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.
'">';
347 print '</td><td> </td>';
348 print '<td class="right"> </td>';
352 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldLastSubscriptionAmount").
'</td><td>';
353 print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.
'">';
354 print '</td><td> </td>';
355 print '<td class="right"> </td>';
359 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldEndLastSubscription").
'</td><td>';
360 print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.
'">';
361 print '</td><td> </td>';
362 print '<td class="right"> </td>';
371 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'"></div>';
380 if (!empty($conf->global->LDAP_MEMBER_ACTIVE))
382 $butlabel = $langs->trans(
"LDAPTestSynchroMember");
383 $testlabel =
'testmember';
384 $key = $conf->global->LDAP_KEY_MEMBERS;
385 $dn = $conf->global->LDAP_MEMBER_DN;
386 $objectclass = $conf->global->LDAP_MEMBER_OBJECT_CLASS;
391 if (function_exists(
"ldap_connect"))
393 if ($_GET[
"action"] ==
'testmember')
397 $object->initAsSpecimen();
401 $result = $ldap->connect_bind();
405 $info = $object->_load_ldap_info();
406 $dn = $object->_load_ldap_dn($info);
408 $result1 = $ldap->delete($dn);
409 $result2 = $ldap->add($dn, $info, $user);
410 $result3 = $ldap->delete($dn);
415 print '<font class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</font><br>';
418 print '<font class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
419 print ': '.$ldap->error;
421 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
425 print "LDAP input file used for test:<br><br>\n";
426 print nl2br($ldap->dump_content($dn, $info));
430 print '<font class="error">'.$langs->trans(
"LDAPSynchroKO");
431 print ': '.$ldap->error;
433 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
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).
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
Show button test LDAP synchro.
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)
Class to manage members of a foundation.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.