30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
38$langs->loadLangs(array(
"admin",
"errors"));
44$action =
GETPOST(
'action',
'aZ09');
51if ($action ==
'setvalue' && $user->admin) {
58 if (!
dolibarr_set_const($db,
'LDAP_GROUP_OBJECT_CLASS',
GETPOST(
"objectclass",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
64 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_FULLNAME',
GETPOST(
"fieldfullname",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
68 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_DESCRIPTION',
GETPOST(
"fielddescription",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
71 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_GROUPMEMBERS',
GETPOST(
"fieldgroupmembers",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
74 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_GROUPID',
GETPOST(
"fieldgroupid",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
82 $valkey = $conf->global->$key;
84 if (!
dolibarr_set_const($db,
'LDAP_KEY_GROUPS', $valkey,
'chaine', 0,
'', $conf->entity)) {
103$form =
new Form($db);
105llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
106$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
108print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
113if (!function_exists(
"ldap_connect")) {
114 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
120print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescGroups").
'</span><br>';
124print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.newToken().
'">';
125print
'<input type="hidden" name="token" value="'.newToken().
'">';
127print
'<table class="noborder centpercent">';
129print
'<tr class="liste_titre">';
130print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeGroups").
'</td>';
134print
'<!-- LDAP_GROUP_DN -->';
135print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPGroupDn").
'</span></td><td>';
136print
'<input size="48" type="text" name="group" value="'.getDolGlobalString(
'LDAP_GROUP_DN').
'">';
137print
'</td><td>'.$langs->trans(
"LDAPGroupDnExample").
'</td>';
138print
'<td> </td>';
142print
'<!-- LDAP_GROUP_OBJECT_CLASS -->';
143print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPGroupObjectClassList").
'</span></td><td>';
144print
'<input size="48" type="text" name="objectclass" value="'.getDolGlobalString(
'LDAP_GROUP_OBJECT_CLASS').
'">';
145print
'</td><td>'.$langs->trans(
"LDAPGroupObjectClassListExample").
'</td>';
146print
'<td> </td>';
150print
'<!-- LDAP_GROUP_FILTER -->';
151print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFilterConnection").
'</td><td>';
152print
'<input size="48" type="text" name="filter" value="'.getDolGlobalString(
'LDAP_GROUP_FILTER').
'">';
153print
'</td><td>'.$langs->trans(
"LDAPGroupFilterExample").
'</td>';
161print
'<table class="noborder centpercent">';
163print
'<tr class="liste_titre">';
164print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
165print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
166print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
172print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
173print
'<input size="25" type="text" name="fieldfullname" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_FULLNAME').
'">';
174print
'</td><td>'.$langs->trans(
"LDAPFieldCommonNameExample").
'</td>';
175print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_FULLNAME')) ?
' checked' :
'').
"></td>";
188print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldDescription").
'</td><td>';
189print
'<input size="25" type="text" name="fielddescription" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_DESCRIPTION').
'">';
190print
'</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
191print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_DESCRIPTION')) ?
' checked' :
'').
"></td>";
195print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupMembers").
'</td><td>';
196print
'<input size="25" type="text" name="fieldgroupmembers" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPMEMBERS').
'">';
197print
'</td><td>'.$langs->trans(
"LDAPFieldGroupMembersExample").
'</td>';
198print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPMEMBERS')) ?
' checked' :
'').
"></td>";
202print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupid").
'</td><td>';
203print
'<input size="25" type="text" name="fieldgroupid" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPID').
'">';
204print
'</td><td>'.$langs->trans(
"LDAPFieldGroupidExample").
'</td>';
205print
'<td class="right"> </td>';
210print
info_admin($langs->trans(
"LDAPDescValues"));
214print $form->buttonsSaveCancel(
"Modify",
'');
223 $butlabel = $langs->trans(
"LDAPTestSynchroGroup");
224 $testlabel =
'testgroup';
231 $butlabel = $langs->trans(
"LDAPTestSearch");
232 $testlabel =
'testsearchgroup';
239if (function_exists(
"ldap_connect")) {
240 if ($action ==
'testgroup') {
243 $object->initAsSpecimen();
247 $result = $ldap->connect_bind();
250 $info = $object->_load_ldap_info();
251 $dn = $object->_load_ldap_dn($info);
254 if (in_array(
'posixGroup', $info[
'objectclass'])) {
255 $info[
'gidNumber'] = $ldap->getNextGroupGid(
'LDAP_KEY_GROUPS');
258 $result1 = $ldap->delete($dn);
259 $result2 = $ldap->add($dn, $info, $user);
260 $result3 = $ldap->delete($dn);
264 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
267 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
268 print
': '.$ldap->error;
270 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
274 print
"LDAP input file used for test:<br><br>\n";
275 print nl2br($ldap->dump_content($dn, $info));
279 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
280 print
': '.$ldap->error;
282 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
286 if ($action ==
'testsearchgroup') {
291 $result = $ldap->connect_bind();
294 $required_fields = array(
303 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
309 if (is_array($ldapgroups)) {
311 foreach ($ldapgroups as $key => $ldapgroup) {
314 foreach ($required_fields as $value) {
316 $label .= $value.
"=".$ldapgroup[$value].
" ";
319 $liste[$key] = $label;
326 print
"LDAP search for group:<br>\n";
327 print
"search: *<br>\n";
328 print
"userDN: ".getDolGlobalString(
'LDAP_GROUP_DN').
"<br>\n";
329 print
"useridentifier: ".getDolGlobalString(
'LDAP_KEY_GROUPS').
"<br>\n";
330 print
"required_fields: ".implode(
',', $required_fields).
"<br>\n";
331 print
"=> ".count($liste).
" records<br>\n";
335 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
336 print
': '.$ldap->error;
338 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.
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
const SYNCHRO_DOLIBARR_TO_LDAP
Dolibarr to Ldap synchronization.
Class to manage user groups.
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.