32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
48$langs->loadLangs(array(
"admin",
"errors"));
54$action =
GETPOST(
'action',
'aZ09');
61if ($action ==
'setvalue' ) {
68 if (!
dolibarr_set_const($db,
'LDAP_GROUP_OBJECT_CLASS',
GETPOST(
"objectclass",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
74 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_FULLNAME',
GETPOST(
"fieldfullname",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
78 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_DESCRIPTION',
GETPOST(
"fielddescription",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
81 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_GROUPMEMBERS',
GETPOST(
"fieldgroupmembers",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
84 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_GROUPID',
GETPOST(
"fieldgroupid",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
94 if (!
dolibarr_set_const($db,
'LDAP_KEY_GROUPS', $valkey,
'chaine', 0,
'', $conf->entity)) {
113$form =
new Form($db);
115llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP',
'', 0, 0,
'',
'',
'',
'mod-admin page-ldap_groups');
117$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
119print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
124if (!function_exists(
"ldap_connect")) {
125 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
131print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescGroups").
'</span><br>';
135print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
136print
'<input type="hidden" name="token" value="'.newToken().
'">';
138print
'<table class="noborder centpercent">';
140print
'<tr class="liste_titre">';
141print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeGroups").
'</td>';
145print
'<!-- LDAP_GROUP_DN -->';
146print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPGroupDn").
'</span></td><td>';
147print
'<input size="48" type="text" name="group" value="'.getDolGlobalString(
'LDAP_GROUP_DN').
'">';
148print
'</td><td>'.$langs->trans(
"LDAPGroupDnExample").
'</td>';
149print
'<td> </td>';
153print
'<!-- LDAP_GROUP_OBJECT_CLASS -->';
154print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPGroupObjectClassList").
'</span></td><td>';
155print
'<input size="48" type="text" name="objectclass" value="'.getDolGlobalString(
'LDAP_GROUP_OBJECT_CLASS').
'">';
156print
'</td><td>'.$langs->trans(
"LDAPGroupObjectClassListExample").
'</td>';
157print
'<td> </td>';
161print
'<!-- LDAP_GROUP_FILTER -->';
162print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFilterConnection").
'</td><td>';
163print
'<input size="48" type="text" name="filter" value="'.getDolGlobalString(
'LDAP_GROUP_FILTER').
'">';
164print
'</td><td>'.$langs->trans(
"LDAPGroupFilterExample").
'</td>';
172print
'<table class="noborder centpercent">';
174print
'<tr class="liste_titre">';
175print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
176print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
177print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
183print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
184print
'<input size="25" type="text" name="fieldfullname" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_FULLNAME').
'">';
185print
'</td><td>'.$langs->trans(
"LDAPFieldCommonNameExample").
'</td>';
186print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_FULLNAME')) ?
' checked' :
'').
"></td>";
199print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldDescription").
'</td><td>';
200print
'<input size="25" type="text" name="fielddescription" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_DESCRIPTION').
'">';
201print
'</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
202print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_DESCRIPTION')) ?
' checked' :
'').
"></td>";
206print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupMembers").
'</td><td>';
207print
'<input size="25" type="text" name="fieldgroupmembers" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPMEMBERS').
'">';
208print
'</td><td>'.$langs->trans(
"LDAPFieldGroupMembersExample").
'</td>';
209print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPMEMBERS')) ?
' checked' :
'').
"></td>";
213print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupid").
'</td><td>';
214print
'<input size="25" type="text" name="fieldgroupid" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPID').
'">';
215print
'</td><td>'.$langs->trans(
"LDAPFieldGroupidExample").
'</td>';
216print
'<td class="right"> </td>';
221print
info_admin($langs->trans(
"LDAPDescValues"));
225print $form->buttonsSaveCancel(
"Modify",
'');
233if (
getDolGlobalInt(
'LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
234 $butlabel = $langs->trans(
"LDAPTestSynchroGroup");
235 $testlabel =
'testgroup';
241} elseif (
getDolGlobalInt(
'LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
242 $butlabel = $langs->trans(
"LDAPTestSearch");
243 $testlabel =
'testsearchgroup';
250if (function_exists(
"ldap_connect")) {
251 if ($action ==
'testgroup') {
258 $result = $ldap->connectBind();
261 $info =
$object->_load_ldap_info();
262 $dn =
$object->_load_ldap_dn($info);
265 if (in_array(
'posixGroup', $info[
'objectclass'])) {
266 $info[
'gidNumber'] = $ldap->getNextGroupGid(
'LDAP_KEY_GROUPS');
269 $result1 = $ldap->delete($dn);
270 $result2 = $ldap->add($dn, $info, $user);
271 $result3 = $ldap->delete($dn);
275 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
278 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
279 print
': '.$ldap->error;
281 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
285 print
"LDAP input file used for test:<br><br>\n";
286 print nl2br($ldap->dumpContent($dn, $info));
290 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
291 print
': '.$ldap->error;
293 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
297 if ($action ==
'testsearchgroup') {
302 $result = $ldap->connectBind();
305 $required_fields = array(
314 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
321 if (is_array($ldapgroups)) {
322 foreach ($ldapgroups as $key => $ldapgroup) {
325 foreach ($required_fields as $value) {
327 $label .= $value.
"=".$ldapgroup[$value].
" ";
330 $liste[$key] = $label;
337 print
"LDAP search for group:<br>\n";
338 print
"search: *<br>\n";
339 print
"userDN: ".getDolGlobalString(
'LDAP_GROUP_DN').
"<br>\n";
340 print
"useridentifier: ".getDolGlobalString(
'LDAP_KEY_GROUPS').
"<br>\n";
341 print
"required_fields: ".implode(
',', $required_fields).
"<br>\n";
342 print
"=> ".count($liste).
" records<br>\n";
346 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
347 print
': '.$ldap->error;
349 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
if(! $sortfield) if(! $sortorder) $object
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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage LDAP features.
Class to manage user groups.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML 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.