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' && $user->admin) {
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');
116$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
118print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
123if (!function_exists(
"ldap_connect")) {
124 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
130print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescGroups").
'</span><br>';
134print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
135print
'<input type="hidden" name="token" value="'.newToken().
'">';
137print
'<table class="noborder centpercent">';
139print
'<tr class="liste_titre">';
140print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeGroups").
'</td>';
144print
'<!-- LDAP_GROUP_DN -->';
145print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPGroupDn").
'</span></td><td>';
146print
'<input size="48" type="text" name="group" value="'.getDolGlobalString(
'LDAP_GROUP_DN').
'">';
147print
'</td><td>'.$langs->trans(
"LDAPGroupDnExample").
'</td>';
148print
'<td> </td>';
152print
'<!-- LDAP_GROUP_OBJECT_CLASS -->';
153print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPGroupObjectClassList").
'</span></td><td>';
154print
'<input size="48" type="text" name="objectclass" value="'.getDolGlobalString(
'LDAP_GROUP_OBJECT_CLASS').
'">';
155print
'</td><td>'.$langs->trans(
"LDAPGroupObjectClassListExample").
'</td>';
156print
'<td> </td>';
160print
'<!-- LDAP_GROUP_FILTER -->';
161print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFilterConnection").
'</td><td>';
162print
'<input size="48" type="text" name="filter" value="'.getDolGlobalString(
'LDAP_GROUP_FILTER').
'">';
163print
'</td><td>'.$langs->trans(
"LDAPGroupFilterExample").
'</td>';
171print
'<table class="noborder centpercent">';
173print
'<tr class="liste_titre">';
174print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
175print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
176print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
182print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
183print
'<input size="25" type="text" name="fieldfullname" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_FULLNAME').
'">';
184print
'</td><td>'.$langs->trans(
"LDAPFieldCommonNameExample").
'</td>';
185print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_FULLNAME')) ?
' checked' :
'').
"></td>";
198print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldDescription").
'</td><td>';
199print
'<input size="25" type="text" name="fielddescription" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_DESCRIPTION').
'">';
200print
'</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
201print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_DESCRIPTION')) ?
' checked' :
'').
"></td>";
205print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupMembers").
'</td><td>';
206print
'<input size="25" type="text" name="fieldgroupmembers" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPMEMBERS').
'">';
207print
'</td><td>'.$langs->trans(
"LDAPFieldGroupMembersExample").
'</td>';
208print
'<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.((getDolGlobalString(
'LDAP_KEY_GROUPS') ==
getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPMEMBERS')) ?
' checked' :
'').
"></td>";
212print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupid").
'</td><td>';
213print
'<input size="25" type="text" name="fieldgroupid" value="'.getDolGlobalString(
'LDAP_GROUP_FIELD_GROUPID').
'">';
214print
'</td><td>'.$langs->trans(
"LDAPFieldGroupidExample").
'</td>';
215print
'<td class="right"> </td>';
220print
info_admin($langs->trans(
"LDAPDescValues"));
224print $form->buttonsSaveCancel(
"Modify",
'');
232if (
getDolGlobalInt(
'LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
233 $butlabel = $langs->trans(
"LDAPTestSynchroGroup");
234 $testlabel =
'testgroup';
240} elseif (
getDolGlobalInt(
'LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
241 $butlabel = $langs->trans(
"LDAPTestSearch");
242 $testlabel =
'testsearchgroup';
249if (function_exists(
"ldap_connect")) {
250 if ($action ==
'testgroup') {
257 $result = $ldap->connectBind();
260 $info =
$object->_load_ldap_info();
261 $dn =
$object->_load_ldap_dn($info);
264 if (in_array(
'posixGroup', $info[
'objectclass'])) {
265 $info[
'gidNumber'] = $ldap->getNextGroupGid(
'LDAP_KEY_GROUPS');
268 $result1 = $ldap->delete($dn);
269 $result2 = $ldap->add($dn, $info, $user);
270 $result3 = $ldap->delete($dn);
274 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
277 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
278 print
': '.$ldap->error;
280 print $langs->trans(
"ErrorLDAPMakeManualTest",
$conf->ldap->dir_temp).
'<br>';
284 print
"LDAP input file used for test:<br><br>\n";
285 print nl2br($ldap->dumpContent($dn, $info));
289 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
290 print
': '.$ldap->error;
292 print $langs->trans(
"ErrorLDAPMakeManualTest",
$conf->ldap->dir_temp).
'<br>';
296 if ($action ==
'testsearchgroup') {
301 $result = $ldap->connectBind();
304 $required_fields = array(
313 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
320 if (is_array($ldapgroups)) {
321 foreach ($ldapgroups as $key => $ldapgroup) {
324 foreach ($required_fields as $value) {
326 $label .= $value.
"=".$ldapgroup[$value].
" ";
329 $liste[$key] = $label;
336 print
"LDAP search for group:<br>\n";
337 print
"search: *<br>\n";
338 print
"userDN: ".getDolGlobalString(
'LDAP_GROUP_DN').
"<br>\n";
339 print
"useridentifier: ".getDolGlobalString(
'LDAP_KEY_GROUPS').
"<br>\n";
340 print
"required_fields: ".implode(
',', $required_fields).
"<br>\n";
341 print
"=> ".count($liste).
" records<br>\n";
345 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
346 print
': '.$ldap->error;
348 print $langs->trans(
"ErrorLDAPMakeManualTest",
$conf->ldap->dir_temp).
'<br>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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).
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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)
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...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.