mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 03:19:05 +02:00
ldap adv conf v3 (good version)
This commit is contained in:
parent
89ba75f466
commit
cb85cff34f
@ -695,22 +695,31 @@ function ldap_process_user_login ($login, $password) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ldap_login_attr = !empty($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) . "=" : '';
|
$dc = $config["ldap_base_dn"];
|
||||||
$ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : '';
|
|
||||||
|
|
||||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
#Search group of this user it belong.
|
||||||
$correct = false;
|
$filter="(cn=" . io_safe_output($login) . ")";
|
||||||
foreach ($ldap_adv_perms as $perm) {
|
$justthese = array("objectclass=group");
|
||||||
$groups = $perm['groups_ldap'];
|
|
||||||
if ($groups[0] == '') {
|
$sr = ldap_search($ds, $dc, $filter, $justthese);
|
||||||
$groups = "";
|
|
||||||
|
$memberof = ldap_get_entries($ds, $sr);
|
||||||
|
|
||||||
|
if ($memberof["count"] == 0 && !isset($memberof[0]["memberof"])) {
|
||||||
|
@ldap_close ($ds);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$groups = ",cn=" . str_replace(",", ",cn=", $groups[0]);
|
$memberof = $memberof[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($memberof["count"]);
|
||||||
|
|
||||||
|
$ldap_base_dn = !empty($config["ldap_base_dn"]) ? "," . io_safe_output($config["ldap_base_dn"]) : '';
|
||||||
|
|
||||||
|
$correct = false;
|
||||||
if(!empty($ldap_base_dn)) {
|
if(!empty($ldap_base_dn)) {
|
||||||
if (strlen($password) != 0 && @ldap_bind($ds, $ldap_login_attr.io_safe_output($login).$groups.$ldap_base_dn, $password) ) {
|
if (strlen($password) != 0 && @ldap_bind($ds, $memberof['dn'], $password) ) {
|
||||||
$correct = true;
|
$correct = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -719,7 +728,6 @@ function ldap_process_user_login ($login, $password) {
|
|||||||
$correct = true;
|
$correct = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@ldap_close ($ds);
|
@ldap_close ($ds);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user