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)) {
107 if (!
dolibarr_set_const($db,
'LDAP_KEY_CONTACTS', $valkey,
'chaine', 0,
'', $conf->entity)) {
126$form =
new Form($db);
128llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
129$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
131print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
136if (!function_exists(
"ldap_connect")) {
137 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
143print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescContact").
'</span><br>';
146print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.newToken().
'">';
147print
'<input type="hidden" name="token" value="'.newToken().
'">';
149print
'<table class="noborder centpercent">';
151print
'<tr class="liste_titre">';
152print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeContacts").
'</td>';
156print
'<!-- LDAP_CONTACT_DN -->';
157print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactDn").
'</span></td><td>';
158print
'<input size="48" type="text" name="contactdn" value="' .
getDolGlobalString(
'LDAP_CONTACT_DN').
'">';
159print
'</td><td>'.$langs->trans(
"LDAPContactDnExample").
'</td>';
160print
'<td> </td>';
164print
'<!-- LDAP_CONTACT_OBJECT_CLASS -->';
165print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactObjectClassList").
'</span></td><td>';
166print
'<input size="48" type="text" name="objectclass" value="' .
getDolGlobalString(
'LDAP_CONTACT_OBJECT_CLASS').
'">';
167print
'</td><td>'.$langs->trans(
"LDAPContactObjectClassListExample").
'</td>';
168print
'<td> </td>';
173print
'<table class="noborder centpercent">';
175print
'<tr class="liste_titre">';
176print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
177print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
178print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
182print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFullname").
'</td><td>';
183print
'<input size="25" type="text" name="fieldfullname" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_FULLNAME').
'">';
184print
'</td><td>'.$langs->trans(
"LDAPFieldFullnameExample").
'</td>';
185print
'<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>";
189print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
190print
'<input size="25" type="text" name="fieldname" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_NAME').
'">';
191print
'</td><td>'.$langs->trans(
"LDAPFieldNameExample").
'</td>';
192print
'<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>";
196print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstName").
'</td><td>';
197print
'<input size="25" type="text" name="fieldfirstname" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_FIRSTNAME').
'">';
198print
'</td><td>'.$langs->trans(
"LDAPFieldFirstNameExample").
'</td>';
199print
'<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>";
203print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCompany").
'</td><td>';
204print
'<input size="25" type="text" name="fieldcompany" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_COMPANY').
'">';
205print
'</td><td>'.$langs->trans(
"LDAPFieldCompanyExample").
'</td>';
206print
'<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>";
210print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMail").
'</td><td>';
211print
'<input size="25" type="text" name="fieldmail" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_MAIL').
'">';
212print
'</td><td>'.$langs->trans(
"LDAPFieldMailExample").
'</td>';
213print
'<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>";
217print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPhone").
'</td><td>';
218print
'<input size="25" type="text" name="fieldphone" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_PHONE').
'">';
219print
'</td><td>'.$langs->trans(
"LDAPFieldPhoneExample").
'</td>';
220print
'<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>";
224print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomePhone").
'</td><td>';
225print
'<input size="25" type="text" name="fieldhomephone" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_HOMEPHONE').
'">';
226print
'</td><td>'.$langs->trans(
"LDAPFieldHomePhoneExample").
'</td>';
227print
'<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>";
231print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMobile").
'</td><td>';
232print
'<input size="25" type="text" name="fieldmobile" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_MOBILE').
'">';
233print
'</td><td>'.$langs->trans(
"LDAPFieldMobileExample").
'</td>';
234print
'<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>";
238print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFax").
'</td><td>';
239print
'<input size="25" type="text" name="fieldfax" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_FAX').
'">';
240print
'</td><td>'.$langs->trans(
"LDAPFieldFaxExample").
'</td>';
241print
'<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>";
245print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldAddress").
'</td><td>';
246print
'<input size="25" type="text" name="fieldaddress" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_ADDRESS').
'">';
247print
'</td><td>'.$langs->trans(
"LDAPFieldAddressExample").
'</td>';
248print
'<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>";
252print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldZip").
'</td><td>';
253print
'<input size="25" type="text" name="fieldzip" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_ZIP').
'">';
254print
'</td><td>'.$langs->trans(
"LDAPFieldZipExample").
'</td>';
255print
'<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>";
259print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTown").
'</td><td>';
260print
'<input size="25" type="text" name="fieldtown" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_TOWN').
'">';
261print
'</td><td>'.$langs->trans(
"LDAPFieldTownExample").
'</td>';
262print
'<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>";
266print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCountry").
'</td><td>';
267print
'<input size="25" type="text" name="fieldcountry" value="' .
getDolGlobalString(
'LDAP_CONTACT_FIELD_COUNTRY').
'">';
268print
'</td><td> </td>';
269print
'<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>";
274print
info_admin($langs->trans(
"LDAPDescValues"));
278print $form->buttonsSaveCancel(
"Modify",
'');
286$butlabel = $langs->trans(
"LDAPTestSynchroContact");
288$key = $conf->global->LDAP_KEY_CONTACTS;
289$dn = $conf->global->LDAP_CONTACT_DN;
290$objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS;
295if (function_exists(
"ldap_connect")) {
296 if ($_GET[
"action"] ==
'test') {
299 $object->initAsSpecimen();
303 $result = $ldap->connect_bind();
306 $info = $object->_load_ldap_info();
307 $dn = $object->_load_ldap_dn($info);
309 $result1 = $ldap->delete($dn);
310 $result2 = $ldap->add($dn, $info, $user);
311 $result3 = $ldap->delete($dn);
315 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
318 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
319 print
': '.$ldap->error;
321 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
325 print
"LDAP input file used for test:<br><br>\n";
326 print nl2br($ldap->dump_content($dn, $info));
330 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
331 print
': '.$ldap->error;
333 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.