30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37 $langs->loadLangs(array(
"admin",
"errors"));
43 $action =
GETPOST(
'action',
'aZ09');
49 if ($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)) {
131 llxHeader(
'', $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>';
134 print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
139 if (!function_exists(
"ldap_connect")) {
140 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
146 print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescContact").
'</span><br>';
149 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
150 print
'<input type="hidden" name="token" value="'.newToken().
'">';
152 print
'<table class="noborder centpercent">';
154 print
'<tr class="liste_titre">';
155 print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeContacts").
'</td>';
159 print
'<!-- LDAP_CONTACT_DN -->';
160 print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactDn").
'</span></td><td>';
161 print
'<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.
'">';
162 print
'</td><td>'.$langs->trans(
"LDAPContactDnExample").
'</td>';
163 print
'<td> </td>';
167 print
'<!-- LDAP_CONTACT_OBJECT_CLASS -->';
168 print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactObjectClassList").
'</span></td><td>';
169 print
'<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_CONTACT_OBJECT_CLASS.
'">';
170 print
'</td><td>'.$langs->trans(
"LDAPContactObjectClassListExample").
'</td>';
171 print
'<td> </td>';
176 print
'<table class="noborder centpercent">';
178 print
'<tr class="liste_titre">';
179 print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
180 print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
181 print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
185 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFullname").
'</td><td>';
186 print
'<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_CONTACT_FIELD_FULLNAME.
'">';
187 print
'</td><td>'.$langs->trans(
"LDAPFieldFullnameExample").
'</td>';
188 print
'<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>";
192 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
193 print
'<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_CONTACT_FIELD_NAME.
'">';
194 print
'</td><td>'.$langs->trans(
"LDAPFieldNameExample").
'</td>';
195 print
'<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>";
199 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstName").
'</td><td>';
200 print
'<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME.
'">';
201 print
'</td><td>'.$langs->trans(
"LDAPFieldFirstNameExample").
'</td>';
202 print
'<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>";
206 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCompany").
'</td><td>';
207 print
'<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_CONTACT_FIELD_COMPANY.
'">';
208 print
'</td><td>'.$langs->trans(
"LDAPFieldCompanyExample").
'</td>';
209 print
'<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>";
213 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMail").
'</td><td>';
214 print
'<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_CONTACT_FIELD_MAIL.
'">';
215 print
'</td><td>'.$langs->trans(
"LDAPFieldMailExample").
'</td>';
216 print
'<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>";
220 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPhone").
'</td><td>';
221 print
'<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_CONTACT_FIELD_PHONE.
'">';
222 print
'</td><td>'.$langs->trans(
"LDAPFieldPhoneExample").
'</td>';
223 print
'<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>";
227 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomePhone").
'</td><td>';
228 print
'<input size="25" type="text" name="fieldhomephone" value="'.$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE.
'">';
229 print
'</td><td>'.$langs->trans(
"LDAPFieldHomePhoneExample").
'</td>';
230 print
'<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>";
234 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMobile").
'</td><td>';
235 print
'<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_CONTACT_FIELD_MOBILE.
'">';
236 print
'</td><td>'.$langs->trans(
"LDAPFieldMobileExample").
'</td>';
237 print
'<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>";
241 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldSkype").
'</td><td>';
242 print
'<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_CONTACT_FIELD_SKYPE.
'">';
243 print
'</td><td>'.$langs->trans(
"LDAPFieldSkypeExample").
'</td>';
244 print
'<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>";
248 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFax").
'</td><td>';
249 print
'<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_CONTACT_FIELD_FAX.
'">';
250 print
'</td><td>'.$langs->trans(
"LDAPFieldFaxExample").
'</td>';
251 print
'<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>";
255 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldAddress").
'</td><td>';
256 print
'<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_CONTACT_FIELD_ADDRESS.
'">';
257 print
'</td><td>'.$langs->trans(
"LDAPFieldAddressExample").
'</td>';
258 print
'<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>";
262 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldZip").
'</td><td>';
263 print
'<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_CONTACT_FIELD_ZIP.
'">';
264 print
'</td><td>'.$langs->trans(
"LDAPFieldZipExample").
'</td>';
265 print
'<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>";
269 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTown").
'</td><td>';
270 print
'<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_CONTACT_FIELD_TOWN.
'">';
271 print
'</td><td>'.$langs->trans(
"LDAPFieldTownExample").
'</td>';
272 print
'<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>";
276 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCountry").
'</td><td>';
277 print
'<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_CONTACT_FIELD_COUNTRY.
'">';
278 print
'</td><td> </td>';
279 print
'<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>";
284 print
info_admin($langs->trans(
"LDAPDescValues"));
288 print
$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;
305 if (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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information 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.