30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37$langs->loadLangs(array(
"admin",
"errors"));
43$action =
GETPOST(
'action',
'aZ09');
49if ($action ==
'setvalue' && $user->admin) {
67 if (!
dolibarr_set_const($db,
'LDAP_CONTACT_FIELD_FIRSTNAME',
GETPOST(
"fieldfirstname"),
'chaine', 0,
'', $conf->entity)) {
79 if (!
dolibarr_set_const($db,
'LDAP_CONTACT_FIELD_HOMEPHONE',
GETPOST(
"fieldhomephone"),
'chaine', 0,
'', $conf->entity)) {
108 $valkey = $conf->global->$key;
110 if (!
dolibarr_set_const($db,
'LDAP_KEY_CONTACTS', $valkey,
'chaine', 0,
'', $conf->entity)) {
129$form =
new Form($db);
131llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
132$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
134print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
139if (!function_exists(
"ldap_connect")) {
140 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
146print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescContact").
'</span><br>';
149print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.newToken().
'">';
150print
'<input type="hidden" name="token" value="'.newToken().
'">';
152print
'<table class="noborder centpercent">';
154print
'<tr class="liste_titre">';
155print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeContacts").
'</td>';
159print
'<!-- LDAP_CONTACT_DN -->';
160print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactDn").
'</span></td><td>';
161print
'<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.
'">';
162print
'</td><td>'.$langs->trans(
"LDAPContactDnExample").
'</td>';
163print
'<td> </td>';
167print
'<!-- LDAP_CONTACT_OBJECT_CLASS -->';
168print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactObjectClassList").
'</span></td><td>';
169print
'<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_CONTACT_OBJECT_CLASS.
'">';
170print
'</td><td>'.$langs->trans(
"LDAPContactObjectClassListExample").
'</td>';
171print
'<td> </td>';
176print
'<table class="noborder centpercent">';
178print
'<tr class="liste_titre">';
179print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
180print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
181print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
185print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFullname").
'</td><td>';
186print
'<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_CONTACT_FIELD_FULLNAME.
'">';
187print
'</td><td>'.$langs->trans(
"LDAPFieldFullnameExample").
'</td>';
188print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FULLNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FULLNAME ?
' checked' :
'').
"></td>";
192print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
193print
'<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_CONTACT_FIELD_NAME.
'">';
194print
'</td><td>'.$langs->trans(
"LDAPFieldNameExample").
'</td>';
195print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_NAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_NAME ?
' checked' :
'').
"></td>";
199print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstName").
'</td><td>';
200print
'<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME.
'">';
201print
'</td><td>'.$langs->trans(
"LDAPFieldFirstNameExample").
'</td>';
202print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FIRSTNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FIRSTNAME ?
' checked' :
'').
"></td>";
206print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCompany").
'</td><td>';
207print
'<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_CONTACT_FIELD_COMPANY.
'">';
208print
'</td><td>'.$langs->trans(
"LDAPFieldCompanyExample").
'</td>';
209print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COMPANY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COMPANY ?
' checked' :
'').
"></td>";
213print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMail").
'</td><td>';
214print
'<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_CONTACT_FIELD_MAIL.
'">';
215print
'</td><td>'.$langs->trans(
"LDAPFieldMailExample").
'</td>';
216print
'<td class="right"><input type="radio" name="key" value=">LDAP_CONTACT_FIELD_MAIL"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MAIL ?
' checked' :
'').
"></td>";
220print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPhone").
'</td><td>';
221print
'<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_CONTACT_FIELD_PHONE.
'">';
222print
'</td><td>'.$langs->trans(
"LDAPFieldPhoneExample").
'</td>';
223print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_PHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_PHONE ?
' checked' :
'').
"></td>";
227print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomePhone").
'</td><td>';
228print
'<input size="25" type="text" name="fieldhomephone" value="'.$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE.
'">';
229print
'</td><td>'.$langs->trans(
"LDAPFieldHomePhoneExample").
'</td>';
230print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_HOMEPHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_HOMEPHONE ?
' checked' :
'').
"></td>";
234print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMobile").
'</td><td>';
235print
'<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_CONTACT_FIELD_MOBILE.
'">';
236print
'</td><td>'.$langs->trans(
"LDAPFieldMobileExample").
'</td>';
237print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_MOBILE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MOBILE ?
' checked' :
'').
"></td>";
241print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldSkype").
'</td><td>';
242print
'<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_CONTACT_FIELD_SKYPE.
'">';
243print
'</td><td>'.$langs->trans(
"LDAPFieldSkypeExample").
'</td>';
244print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_SKYPE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_SKYPE ?
' checked' :
'').
"></td>";
248print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFax").
'</td><td>';
249print
'<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_CONTACT_FIELD_FAX.
'">';
250print
'</td><td>'.$langs->trans(
"LDAPFieldFaxExample").
'</td>';
251print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FAX"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FAX ?
' checked' :
'').
"></td>";
255print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldAddress").
'</td><td>';
256print
'<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_CONTACT_FIELD_ADDRESS.
'">';
257print
'</td><td>'.$langs->trans(
"LDAPFieldAddressExample").
'</td>';
258print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ADDRESS"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ADDRESS ?
' checked' :
'').
"></td>";
262print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldZip").
'</td><td>';
263print
'<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_CONTACT_FIELD_ZIP.
'">';
264print
'</td><td>'.$langs->trans(
"LDAPFieldZipExample").
'</td>';
265print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ZIP"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ZIP ?
' checked' :
'').
"></td>";
269print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTown").
'</td><td>';
270print
'<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_CONTACT_FIELD_TOWN.
'">';
271print
'</td><td>'.$langs->trans(
"LDAPFieldTownExample").
'</td>';
272print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_TOWN"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_TOWN ?
' checked' :
'').
"></td>";
276print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCountry").
'</td><td>';
277print
'<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_CONTACT_FIELD_COUNTRY.
'">';
278print
'</td><td> </td>';
279print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COUNTRY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COUNTRY ?
' checked' :
'').
"></td>";
284print
info_admin($langs->trans(
"LDAPDescValues"));
288print $form->buttonsSaveCancel(
"Modify",
'');
296$butlabel = $langs->trans(
"LDAPTestSynchroContact");
298$key = $conf->global->LDAP_KEY_CONTACTS;
299$dn = $conf->global->LDAP_CONTACT_DN;
300$objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS;
305if (function_exists(
"ldap_connect")) {
306 if ($_GET[
"action"] ==
'test') {
309 $object->initAsSpecimen();
313 $result = $ldap->connect_bind();
316 $info = $object->_load_ldap_info();
317 $dn = $object->_load_ldap_dn($info);
319 $result1 = $ldap->delete($dn);
320 $result2 = $ldap->add($dn, $info, $user);
321 $result3 = $ldap->delete($dn);
325 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
328 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
329 print
': '.$ldap->error;
331 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
335 print
"LDAP input file used for test:<br><br>\n";
336 print nl2br($ldap->dump_content($dn, $info));
340 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
341 print
': '.$ldap->error;
343 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
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()
Empty header.
Class to manage LDAP features.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.