Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
# $Id: ldap.php 2451 2017-12-05 22:33:27Z tom.houdayer $
|
2 |
# $Id: ldap.php 2452 2017-12-05 22:51:01Z tom.houdayer $
|
3 |
|
3 |
|
4 |
/* written by steweb57 & Rexy */
|
4 |
/* written by steweb57 & Rexy */
|
5 |
/****************************************************************
|
5 |
/****************************************************************
|
6 |
* GLOBAL FILE PATHS *
|
6 |
* GLOBAL FILE PATHS *
|
7 |
*****************************************************************/
|
7 |
*****************************************************************/
|
Line 172... |
Line 172... |
172 |
} else {
|
172 |
} else {
|
173 |
exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
|
173 |
exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
|
174 |
exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
|
174 |
exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
|
175 |
exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
|
175 |
exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
|
176 |
exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_filter/g").' '.CONF_FILE);
|
176 |
exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_filter/g").' '.CONF_FILE);
|
177 |
exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_filter/g").' '.CONF_FILE);
|
177 |
exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
|
178 |
exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
|
178 |
exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
|
179 |
exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
|
179 |
exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
|
180 |
exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
|
180 |
exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
|
181 |
|
181 |
|
182 |
$messages .= '<div style="text-align: center"><br>';
|
182 |
$messages .= '<div style="text-align: center"><br>';
|
Line 210... |
Line 210... |
210 |
// LDAP configuration params
|
210 |
// LDAP configuration params
|
211 |
$ldap_status = ($conf['LDAP'] === 'on');
|
211 |
$ldap_status = ($conf['LDAP'] === 'on');
|
212 |
$ldap_server = $conf['LDAP_SERVER'];
|
212 |
$ldap_server = $conf['LDAP_SERVER'];
|
213 |
$ldap_identity = $conf['LDAP_USER'];
|
213 |
$ldap_identity = $conf['LDAP_USER'];
|
214 |
$ldap_password = $conf['LDAP_PASSWORD'];
|
214 |
$ldap_password = $conf['LDAP_PASSWORD'];
|
215 |
$ldap_basedn = $conf['LDAP_BASE'];
|
215 |
$ldap_base_dn = $conf['LDAP_BASE'];
|
216 |
$ldap_filter = $conf['LDAP_UID'];
|
216 |
$ldap_filter = $conf['LDAP_UID'];
|
217 |
$ldap_base_filter = $conf['LDAP_FILTER'];
|
217 |
$ldap_base_filter = $conf['LDAP_FILTER'];
|
218 |
|
218 |
|
219 |
// TODO : check LDAP PHP extension loaded?
|
219 |
// TODO : check LDAP PHP extension loaded?
|
220 |
// if (!extension_loaded('ldap')) {
|
220 |
// if (!extension_loaded('ldap')) {
|
Line 227... |
Line 227... |
227 |
$new_ldap_server = explode('//', $ldap_server); // pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com"
|
227 |
$new_ldap_server = explode('//', $ldap_server); // pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com"
|
228 |
} else {
|
228 |
} else {
|
229 |
$new_ldap_server = $ldap_server;
|
229 |
$new_ldap_server = $ldap_server;
|
230 |
}
|
230 |
}
|
231 |
if ($ldap_status) {
|
231 |
if ($ldap_status) {
|
232 |
$serverCheckResult = ldap_checkServerConfig($new_ldap_server, $ldap_identity, $ldap_password, $ldap_basedn, $ldap_filter);
|
232 |
$serverCheckResult = ldap_checkServerConfig($new_ldap_server, $ldap_identity, $ldap_password, $ldap_base_dn, $ldap_filter);
|
233 |
}
|
233 |
}
|
234 |
|
234 |
|
235 |
?>
|
235 |
?>
|
236 |
<!DOCTYPE html>
|
236 |
<!DOCTYPE html>
|
237 |
<html>
|
237 |
<html>
|
Line 314... |
Line 314... |
314 |
<dt>
|
314 |
<dt>
|
315 |
<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
|
315 |
<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
|
316 |
<?= $l_ldap_base_dn_text ?>
|
316 |
<?= $l_ldap_base_dn_text ?>
|
317 |
</dt>
|
317 |
</dt>
|
318 |
<dd>
|
318 |
<dd>
|
319 |
<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_basedn) ?>">
|
319 |
<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>">
|
320 |
</dd>
|
320 |
</dd>
|
321 |
</dl>
|
321 |
</dl>
|
322 |
<dl>
|
322 |
<dl>
|
323 |
<dt>
|
323 |
<dt>
|
324 |
<label for="ldap_filter"><?= $l_ldap_filter_label ?></label><br>
|
324 |
<label for="ldap_filter"><?= $l_ldap_filter_label ?></label><br>
|