Go to the documentation of this file.
30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
38 $langs->loadLangs(array(
'admin',
'errors'));
44 $action =
GETPOST(
'action',
'aZ09');
51 if ($action ==
'setvalue' && $user->admin) {
62 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_TYPE_FIELD_FULLNAME',
GETPOST(
"fieldfullname"),
'chaine', 0,
'', $conf->entity)) {
65 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION',
GETPOST(
"fielddescription"),
'chaine', 0,
'', $conf->entity)) {
68 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS',
GETPOST(
"fieldmembertypemembers"),
'chaine', 0,
'', $conf->entity)) {
76 $valkey = $conf->global->$key;
78 if (!
dolibarr_set_const($db,
'LDAP_KEY_MEMBERS_TYPES', $valkey,
'chaine', 0,
'', $conf->entity)) {
97 llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
98 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
100 print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
105 if (!function_exists(
"ldap_connect")) {
106 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
112 print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescMembersTypes").
'</span><br>';
116 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
117 print
'<input type="hidden" name="token" value="'.newToken().
'">';
121 print
'<table class="noborder centpercent">';
123 print
'<tr class="liste_titre">';
124 print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeMembersTypes").
'</td>';
128 print
'<!-- LDAP_MEMBER_TYPE_DN -->';
129 print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPMemberTypeDn").
'</span></td><td>';
130 print
'<input size="48" type="text" name="membertype" value="'.$conf->global->LDAP_MEMBER_TYPE_DN.
'">';
131 print
'</td><td>'.$langs->trans(
"LDAPMemberTypepDnExample").
'</td>';
132 print
'<td> </td>';
136 print
'<!-- LDAP_MEMBER_TYPE_OBJECT_CLASS -->';
137 print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPMemberTypeObjectClassList").
'</span></td><td>';
138 print
'<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS.
'">';
139 print
'</td><td>'.$langs->trans(
"LDAPMemberTypeObjectClassListExample").
'</td>';
140 print
'<td> </td>';
147 print
'<table class="noborder centpercent">';
149 print
'<tr class="liste_titre">';
150 print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
151 print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
152 print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
158 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
159 print
'<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME.
'">';
160 print
'</td><td>'.$langs->trans(
"LDAPFieldCommonNameExample").
'</td>';
161 print
'<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME) ?
' checked' :
'').
"></td>";
165 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldDescription").
'</td><td>';
166 print
'<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION.
'">';
167 print
'</td><td>'.$langs->trans(
"LDAPFieldDescriptionExample").
'</td>';
168 print
'<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION) ?
' checked' :
'').
"></td>";
172 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldGroupMembers").
'</td><td>';
173 print
'<input size="25" type="text" name="fieldmembertypemembers" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS.
'">';
174 print
'</td><td>'.$langs->trans(
"LDAPFieldGroupMembersExample").
'</td>';
175 print
'<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES == $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS) ?
' checked' :
'').
"></td>";
180 print
info_admin($langs->trans(
"LDAPDescValues"));
184 print
$form->buttonsSaveCancel(
"Modify",
'');
193 $butlabel = $langs->trans(
"LDAPTestSynchroMemberType");
194 $testlabel =
'testmembertype';
195 $key = $conf->global->LDAP_KEY_MEMBERS_TYPES;
196 $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
197 $objectclass = $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS;
202 if (function_exists(
"ldap_connect")) {
203 if ($_GET[
"action"] ==
'testmembertype') {
206 $object->initAsSpecimen();
210 $result = $ldap->connect_bind();
213 $info = $object->_load_ldap_info();
214 $dn = $object->_load_ldap_dn($info);
217 if (in_array(
'posixGroup', $info[
'objectclass'])) {
218 $info[
'gidNumber'] = $ldap->getNextGroupGid(
'LDAP_KEY_MEMBERS_TYPES');
221 $result1 = $ldap->delete($dn);
222 $result2 = $ldap->add($dn, $info, $user);
223 $result3 = $ldap->delete($dn);
227 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
230 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
231 print
': '.$ldap->error;
233 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
237 print
"LDAP input file used for test:<br><br>\n";
238 print nl2br($ldap->dump_content($dn, $info));
242 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
243 print
': '.$ldap->error;
245 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
Class to manage LDAP features.
Class to manage members type.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
const SYNCHRO_DOLIBARR_TO_LDAP
Dolibarr to Ldap synchronization.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
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).
ldap_prepare_head()
Initialize the array of tabs for customer invoice.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
Show button test LDAP synchro.