29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
37 $langs->loadLangs(array(
"admin",
"errors"));
42 $action =
GETPOST(
'action',
'aZ09');
49 if ($action ==
'setvalue' && $user->admin)
55 if (!
dolibarr_set_const($db,
'LDAP_GROUP_OBJECT_CLASS',
GETPOST(
"objectclass",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
57 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_FULLNAME',
GETPOST(
"fieldfullname",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
59 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_DESCRIPTION',
GETPOST(
"fielddescription",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
60 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_GROUPMEMBERS',
GETPOST(
"fieldgroupmembers",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
61 if (!
dolibarr_set_const($db,
'LDAP_GROUP_FIELD_GROUPID',
GETPOST(
"fieldgroupid",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) $error++;
66 if ($key) $valkey = $conf->global->$key;
67 if (!
dolibarr_set_const($db,
'LDAP_KEY_GROUPS', $valkey,
'chaine', 0,
'', $conf->entity)) $error++;
85 llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
86 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
93 if (!function_exists(
"ldap_connect"))
95 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"), null,
'errors');
101 print $langs->trans(
"LDAPDescGroups").
'<br>';
105 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue">';
106 print '<input type="hidden" name="token" value="'.newToken().
'">';
108 $form =
new Form($db);
110 print '<table class="noborder centpercent">';
112 print '<tr class="liste_titre">';
113 print '<td colspan="4">'.$langs->trans(
"LDAPSynchronizeGroups").
'</td>';
117 print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans(
"LDAPGroupDn").
'</span></td><td>';
118 print '<input size="48" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.
'">';
119 print '</td><td>'.$langs->trans(
"LDAPGroupDnExample").
'</td>';
120 print '<td> </td>';
124 print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans(
"LDAPGroupObjectClassList").
'</span></td><td>';
125 print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_GROUP_OBJECT_CLASS.
'">';
126 print '</td><td>'.$langs->trans(
"LDAPGroupObjectClassListExample").
'</td>';
127 print '<td> </td>';
132 print '<table class="noborder centpercent">';
134 print '<tr class="liste_titre">';
135 print '<td width="25%">'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
136 print '<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
137 print '<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
143 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
144 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_GROUP_FIELD_FULLNAME.
'">';
145 print '</td><td>'.$langs->trans(
"LDAPFieldCommonNameExample").
'</td>';
146 print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_FULLNAME) ?
' checked' :
'').
"></td>";
159 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldDescription").
'</td><td>';
160 print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_GROUP_FIELD_DESCRIPTION.
'">';
161 print '</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
162 print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_DESCRIPTION) ?
' checked' :
'').
"></td>";
166 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupMembers").
'</td><td>';
167 print '<input size="25" type="text" name="fieldgroupmembers" value="'.$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS.
'">';
168 print '</td><td>'.$langs->trans(
"LDAPFieldGroupMembersExample").
'</td>';
169 print '<td class="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS == $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS) ?
' checked' :
'').
"></td>";
173 print '<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupid").
'</td><td>';
174 print '<input size="25" type="text" name="fieldgroupid" value="'.$conf->global->LDAP_GROUP_FIELD_GROUPID.
'">';
175 print '</td><td>'.$langs->trans(
"LDAPFieldGroupidExample").
'</td>';
176 print '<td class="right"> </td>';
185 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'"></div>';
193 if ($conf->global->LDAP_SYNCHRO_ACTIVE ==
'dolibarr2ldap')
195 $butlabel = $langs->trans(
"LDAPTestSynchroGroup");
196 $testlabel =
'testgroup';
197 $key = $conf->global->LDAP_KEY_GROUPS;
198 $dn = $conf->global->LDAP_GROUP_DN;
199 $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
204 if (function_exists(
"ldap_connect"))
206 if ($_GET[
"action"] ==
'testgroup')
210 $object->initAsSpecimen();
214 $result = $ldap->connect_bind();
218 $info = $object->_load_ldap_info();
219 $dn = $object->_load_ldap_dn($info);
222 if (in_array(
'posixGroup', $info[
'objectclass'])) {
223 $info[
'gidNumber'] = $ldap->getNextGroupGid(
'LDAP_KEY_GROUPS');
226 $result1 = $ldap->delete($dn);
227 $result2 = $ldap->add($dn, $info, $user);
228 $result3 = $ldap->delete($dn);
233 print '<font class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</font><br>';
236 print '<font class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
237 print ': '.$ldap->error;
239 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
243 print "LDAP input file used for test:<br><br>\n";
244 print nl2br($ldap->dump_content($dn, $info));
248 print '<font class="error">'.$langs->trans(
"LDAPSynchroKO");
249 print ': '.$ldap->error;
251 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
Class to manage user groups.
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
Show button test LDAP synchro.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class to manage LDAP features.
print
Draft customers invoices.
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.
ldap_prepare_head()
Initialize the array of tabs for customer invoice.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.