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.
'/core/class/ldap.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formldap.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
37 $langs->loadLangs(array(
"admin",
"ldap"));
43 $action =
GETPOST(
'action',
'aZ09');
46 $hookmanager->initHooks(array(
'adminldap',
'globaladmin'));
53 $parameters = array();
54 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
59 if (empty($reshook)) {
60 if ($action ==
'setvalue' && $user->admin) {
68 if (!
dolibarr_set_const($db,
'LDAP_USERACCOUNTCONTROL',
GETPOST(
"userAccountControl",
'int'),
'chaine', 0,
'', $conf->entity)) {
71 if (!
dolibarr_set_const($db,
'LDAP_SERVER_PROTOCOLVERSION',
GETPOST(
"LDAP_SERVER_PROTOCOLVERSION",
'aZ09'),
'chaine', 0,
'', $conf->entity)) {
77 if (!
dolibarr_set_const($db,
'LDAP_SERVER_HOST_SLAVE',
GETPOST(
"slave",
'alphanohtml'),
'chaine', 0,
'', $conf->entity)) {
104 if (!
dolibarr_set_const($db,
'LDAP_MEMBER_TYPE_ACTIVE',
GETPOST(
"activememberstypes",
'aZ09'),
'chaine', 0,
'', $conf->entity)) {
107 if (!
dolibarr_set_const($db,
'LDAP_PASSWORD_HASH_TYPE',
GETPOST(
"LDAP_PASSWORD_HASH_TYPE",
'aZ09'),
'chaine', 0,
'', $conf->entity)) {
125 llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
127 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
129 print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
134 if (!function_exists(
"ldap_connect")) {
135 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
142 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
143 print
'<input type="hidden" name="token" value="'.newToken().
'">';
147 print
'<table class="noborder centpercent">';
150 print
'<tr class="liste_titre">';
151 print
'<td colspan="3">'.$langs->trans(
"LDAPSynchronization").
'</td>';
156 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnSynchroActive").
'</td><td>';
157 print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_SYNCHRO_ACTIVE'),
'activesynchro');
158 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPDnSynchroActiveExample").
'</span>';
159 if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && empty($conf->global->LDAP_USER_DN)) {
160 print
'<br><span class="error">'.$langs->trans(
"LDAPSetupNotComplete").
'</span>';
166 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnContactActive").
'</td><td>';
168 print
'</td><td><span class="opacitymedium">' . $langs->trans(
"LDAPDnContactActiveExample") .
'</span></td></tr>';
173 print
'<tr class="oddeven"><td>' . $langs->trans(
"LDAPDnMemberActive") .
'</td><td>';
174 print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_MEMBER_ACTIVE'),
'activemembers', array(), 2);
175 print
'</td><td><span class="opacitymedium">' . $langs->trans(
"LDAPDnMemberActiveExample") .
'</span></td></tr>';
180 print
'<tr class="oddeven"><td>' . $langs->trans(
"LDAPDnMemberTypeActive") .
'</td><td>';
181 print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_MEMBER_TYPE_ACTIVE'),
'activememberstypes', array(), 2);
182 print
'</td><td><span class="opacitymedium">' . $langs->trans(
"LDAPDnMemberTypeActiveExample") .
'</span></td></tr>';
186 $parameters = array();
187 $reshook = $hookmanager->executeHooks(
'addAdminLdapOptions', $parameters);
188 print $hookmanager->resPrint;
190 print
'<tr class="liste_titre">';
191 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
192 print
'<td>'.$langs->trans(
"Value").
'</td>';
193 print
'<td>'.$langs->trans(
"Example").
'</td>';
197 print
'<tr class="oddeven"><td>'.$langs->trans(
"Type").
'</td><td>';
198 print $formldap->selectLdapServerType(
getDolGlobalString(
'LDAP_SERVER_TYPE'),
'type');
199 print
'</td><td> </td></tr>';
202 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPUserAccountControl").
'</td><td>';
203 print
'<input class="width75" type="text" name="userAccountControl" value="'.getDolGlobalString(
'LDAP_USERACCOUNTCONTROL',
'512').
'">';
204 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPUserAccountControlExample").
'</span></td></tr>';
207 print
'<tr class="oddeven"><td>'.$langs->trans(
"Version").
'</td><td>';
208 print $formldap->selectLdapServerProtocolVersion(
getDolGlobalString(
'LDAP_SERVER_PROTOCOLVERSION'),
'LDAP_SERVER_PROTOCOLVERSION');
209 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerProtocolVersion").
'</span></td></tr>';
212 print
'<tr class="oddeven"><td>';
213 print $langs->trans(
"LDAPPrimaryServer").
'</td><td>';
214 print
'<input class="minwidth200" type="text" name="host" value="'.getDolGlobalString(
'LDAP_SERVER_HOST').
'">';
215 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerExample").
'</span></td></tr>';
218 print
'<tr class="oddeven"><td>';
219 print $langs->trans(
"LDAPSecondaryServer").
'</td><td>';
220 print
'<input class="minwidth200" type="text" name="slave" value="'.getDolGlobalString(
'LDAP_SERVER_HOST_SLAVE').
'">';
221 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerExample").
'</span></td></tr>';
224 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerPort").
'</td><td>';
225 print
'<input class="width75" type="text" name="port" value="'.getDolGlobalString(
'LDAP_SERVER_PORT',
'389').
'">';
226 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerPortExample").
'</span></td></tr>';
229 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerDn").
'</td><td>';
230 print
'<input class="minwidth300" type="text" name="dn" value="'.getDolGlobalString(
'LDAP_SERVER_DN').
'">';
231 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerDnExample").
'</span></td></tr>';
234 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerUseTLS").
'</td><td>';
236 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerUseTLSExample").
'</span></td></tr>';
239 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPPasswordHashType").
'</td><td>';
240 print $formldap->selectLdapPasswordHashType(
getDolGlobalString(
'LDAP_PASSWORD_HASH_TYPE'),
'LDAP_PASSWORD_HASH_TYPE');
241 print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPPasswordHashTypeExample").
'</span></td></tr>';
243 print
'<tr class="liste_titre">';
244 print
'<td colspan="3">'.$langs->trans(
"ForANonAnonymousAccess").
'</td>';
248 print
'<!-- LDAP_ADMIN_DN -->';
249 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPAdminDn").
'</td><td>';
250 print
'<input class="minwidth300" type="text" name="admin" value="'.getDolGlobalString(
'LDAP_ADMIN_DN').
'">';
251 print
'</td><td class="maxwidthhalf"><span class="opacitymedium">'.$langs->trans(
"LDAPAdminDnExample").
'</span></td></tr>';
254 print
'<!-- LDAP_ADMIN_PASS -->';
255 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPPassword").
'</td><td>';
256 print
'<input class="minwidth150" type="password" name="pass" value="'.dol_escape_htmltag(
getDolGlobalString(
'LDAP_ADMIN_PASS')).
'">';
258 print
'</td><td><span class="opacitymedium">'.$langs->trans(
'Password').
' (ex: secret)</span></td></tr>';
264 print
$form->buttonsSaveCancel(
"Modify",
'');
274 if (function_exists(
"ldap_connect")) {
275 if (!empty($conf->global->LDAP_SERVER_HOST)) {
276 print
'<a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=test">'.$langs->trans(
"LDAPTestConnect").
'</a><br><br>';
279 if ($action ==
'test') {
282 $result = $ldap->connect_bind();
286 print
'<span class="ok">'.$langs->trans(
"LDAPTCPConnectOK", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT')).
'</span>';
289 if (!empty($conf->global->LDAP_ADMIN_DN) && !empty($conf->global->LDAP_ADMIN_PASS)) {
292 print
'<span class="ok">'.$langs->trans(
"LDAPBindOK", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace(
'/./i',
'*', $conf->global->LDAP_ADMIN_PASS)).
'</span>';
296 print
'<span class="error">'.$langs->trans(
"LDAPBindKO", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace(
'/./i',
'*', $conf->global->LDAP_ADMIN_PASS)).
'</span>';
298 print $langs->trans(
"Error").
' '.$ldap->error;
303 print
'<span class="warning">'.$langs->trans(
"LDAPNoUserOrPasswordProvidedAccessIsReadOnly").
'</span>';
309 if (($ldap->getVersion() == 3)) {
311 print
'<span class="ok">'.$langs->trans(
"LDAPSetupForVersion3").
'</span>';
315 print
'<span class="ok">'.$langs->trans(
"LDAPSetupForVersion2").
'</span>';
322 print
'<span class="error">'.$langs->trans(
"LDAPTCPConnectKO", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT')).
'</span>';
324 print $langs->trans(
"Error").
' '.$ldap->error;
Class to manage LDAP features.
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.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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).
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
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.