31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formldap.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
46$langs->loadLangs(array(
"admin",
"ldap"));
52$action =
GETPOST(
'action',
'aZ09');
55$hookmanager->initHooks(array(
'adminldap',
'globaladmin'));
63$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
69 if ($action ==
'setvalue' && $user->admin) {
134llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP',
'', 0, 0,
'',
'',
'',
'mod-admin page-ldap');
136$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
138print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
143if (!function_exists(
"ldap_connect")) {
144 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"),
null,
'errors');
148$form =
new Form($db);
151print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
152print
'<input type="hidden" name="token" value="'.newToken().
'">';
156print
'<table class="noborder centpercent">';
159print
'<tr class="liste_titre">';
160print
'<td colspan="3">'.$langs->trans(
"LDAPSynchronization").
'</td>';
165print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnSynchroActive").
'</td><td>';
166print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_SYNCHRO_ACTIVE'),
'activesynchro');
167print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPDnSynchroActiveExample").
'</span>';
169 print
'<br><span class="error">'.$langs->trans(
"LDAPSetupNotComplete").
'</span>';
174if (isModEnabled(
'societe')) {
175 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPDnContactActive").
'</td><td>';
176 print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_CONTACT_ACTIVE'),
'activecontact', array(Ldap::SYNCHRO_LDAP_TO_DOLIBARR));
177 print
'</td><td><span class="opacitymedium">' . $langs->trans(
"LDAPDnContactActiveExample") .
'</span></td></tr>';
181if (isModEnabled(
'member')) {
182 print
'<tr class="oddeven"><td>' . $langs->trans(
"LDAPDnMemberActive") .
'</td><td>';
183 print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_MEMBER_ACTIVE'),
'activemembers', array(), 2);
184 print
'</td><td><span class="opacitymedium">' . $langs->trans(
"LDAPDnMemberActiveExample") .
'</span></td></tr>';
188if (isModEnabled(
'member')) {
189 print
'<tr class="oddeven"><td>' . $langs->trans(
"LDAPDnMemberTypeActive") .
'</td><td>';
190 print $formldap->selectLdapDnSynchroActive(
getDolGlobalInt(
'LDAP_MEMBER_TYPE_ACTIVE'),
'activememberstypes', array(), 2);
191 print
'</td><td><span class="opacitymedium">' . $langs->trans(
"LDAPDnMemberTypeActiveExample") .
'</span></td></tr>';
195$parameters = array();
196$reshook = $hookmanager->executeHooks(
'addAdminLdapOptions', $parameters);
197print $hookmanager->resPrint;
199print
'<tr class="liste_titre">';
200print
'<td>'.$langs->trans(
"Parameter").
'</td>';
201print
'<td>'.$langs->trans(
"Value").
'</td>';
202print
'<td>'.$langs->trans(
"Example").
'</td>';
206print
'<tr class="oddeven"><td>'.$langs->trans(
"Type").
'</td><td>';
208print
'</td><td> </td></tr>';
211print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPUserAccountControl").
'</td><td>';
212print
'<input class="width75" type="text" name="userAccountControl" value="'.getDolGlobalString(
'LDAP_USERACCOUNTCONTROL',
'512').
'">';
213print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPUserAccountControlExample").
'</span></td></tr>';
216print
'<tr class="oddeven"><td>'.$langs->trans(
"Version").
'</td><td>';
217print $formldap->selectLdapServerProtocolVersion(
getDolGlobalString(
'LDAP_SERVER_PROTOCOLVERSION'),
'LDAP_SERVER_PROTOCOLVERSION');
218print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerProtocolVersion").
'</span></td></tr>';
221print
'<tr class="oddeven"><td>';
222print $langs->trans(
"LDAPPrimaryServer").
'</td><td>';
223print
'<input class="minwidth200" type="text" name="host" value="'.getDolGlobalString(
'LDAP_SERVER_HOST').
'">';
224print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerExample").
'</span></td></tr>';
227print
'<tr class="oddeven"><td>';
228print $langs->trans(
"LDAPSecondaryServer").
'</td><td>';
229print
'<input class="minwidth200" type="text" name="slave" value="'.getDolGlobalString(
'LDAP_SERVER_HOST_SLAVE').
'">';
230print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerExample").
'</span></td></tr>';
233print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerPort").
'</td><td>';
234print
'<input class="width75" type="text" name="port" value="'.getDolGlobalString(
'LDAP_SERVER_PORT',
'389').
'">';
235print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerPortExample").
'</span></td></tr>';
238print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerDn").
'</td><td>';
239print
'<input class="minwidth300" type="text" name="dn" value="'.getDolGlobalString(
'LDAP_SERVER_DN').
'">';
240print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerDnExample").
'</span></td></tr>';
243print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPServerUseTLS").
'</td><td>';
244print $form->selectyesno(
'usetls',
getDolGlobalInt(
'LDAP_SERVER_USE_TLS'), 1);
245print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPServerUseTLSExample").
'</span></td></tr>';
248print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPPasswordHashType").
'</td><td>';
249print $formldap->selectLdapPasswordHashType(
getDolGlobalString(
'LDAP_PASSWORD_HASH_TYPE'),
'LDAP_PASSWORD_HASH_TYPE');
250print
'</td><td><span class="opacitymedium">'.$langs->trans(
"LDAPPasswordHashTypeExample").
'</span></td></tr>';
252print
'<tr class="liste_titre">';
253print
'<td colspan="3">'.$langs->trans(
"ForANonAnonymousAccess").
'</td>';
257print
'<!-- LDAP_ADMIN_DN -->';
258print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPAdminDn").
'</td><td>';
259print
'<input class="minwidth300" type="text" name="admin" value="'.getDolGlobalString(
'LDAP_ADMIN_DN').
'">';
260print
'</td><td class="maxwidthhalf"><span class="opacitymedium">'.$langs->trans(
"LDAPAdminDnExample").
'</span></td></tr>';
263print
'<!-- LDAP_ADMIN_PASS -->';
264print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPPassword").
'</td><td>';
265print
'<input class="minwidth150" type="password" name="pass" value="'.dol_escape_htmltag(
getDolGlobalString(
'LDAP_ADMIN_PASS')).
'">';
267print
'</td><td><span class="opacitymedium">'.$langs->trans(
'Password').
' (ex: secret)</span></td></tr>';
273print $form->buttonsSaveCancel(
"Modify",
'');
283if (function_exists(
"ldap_connect")) {
285 print
'<a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=test">'.$langs->trans(
"LDAPTestConnect").
'</a><br><br>';
288 if ($action ==
'test') {
291 $result = $ldap->connectBind();
295 print
'<span class="ok">'.$langs->trans(
"LDAPTCPConnectOK", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT')).
'</span>';
301 print
'<span class="ok">'.$langs->trans(
"LDAPBindOK", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT'),
getDolGlobalString(
'LDAP_ADMIN_DN'), preg_replace(
'/./i',
'*',
$conf->global->LDAP_ADMIN_PASS)).
'</span>';
305 print
'<span class="error">'.$langs->trans(
"LDAPBindKO", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT'),
getDolGlobalString(
'LDAP_ADMIN_DN'), preg_replace(
'/./i',
'*',
$conf->global->LDAP_ADMIN_PASS)).
'</span>';
307 print $langs->trans(
"Error").
' '.$ldap->error;
312 print
'<span class="warning">'.$langs->trans(
"LDAPNoUserOrPasswordProvidedAccessIsReadOnly").
'</span>';
318 if (($ldap->getVersion() == 3)) {
320 print
'<span class="ok">'.$langs->trans(
"LDAPSetupForVersion3").
'</span>';
324 print
'<span class="ok">'.$langs->trans(
"LDAPSetupForVersion2").
'</span>';
331 print
'<span class="error">'.$langs->trans(
"LDAPTCPConnectKO", $ldap->connectedServer,
getDolGlobalString(
'LDAP_SERVER_PORT')).
'</span>';
333 print $langs->trans(
"Error").
' '.$ldap->error;
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.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
ldap_prepare_head()
Initialize the array of tabs for customer invoice.
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.