mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 23:24:07 +01:00
* [FIX] Closes #204. Fixed LDAP group search when ADS is set. Thanks to @vplanas
This commit is contained in:
@@ -96,7 +96,7 @@ class Auth
|
||||
}
|
||||
// Comprobamos que el usuario está en el grupo indicado buscando en los atributos del grupo
|
||||
} else {
|
||||
$ldapGroupAccess = (Ldap::searchUserInGroup($userDN) || LdapADS::searchADUserInGroup($userLogin));
|
||||
$ldapGroupAccess = (Ldap::isADS()) ? LdapADS::searchADUserInGroup($userLogin) : Ldap::searchUserInGroup($userDN);
|
||||
}
|
||||
} else {
|
||||
$ldapGroupAccess = true;
|
||||
@@ -236,15 +236,6 @@ class Auth
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve el typo de autentificación del servidor web
|
||||
* @return string
|
||||
*/
|
||||
public static function getServerAuthType()
|
||||
{
|
||||
return strtoupper($_SERVER['AUTH_TYPE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el nombre del usuario autentificado por el servidor web
|
||||
*
|
||||
@@ -260,4 +251,14 @@ class Auth
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve el typo de autentificación del servidor web
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getServerAuthType()
|
||||
{
|
||||
return strtoupper($_SERVER['AUTH_TYPE']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class Ldap
|
||||
// Variabla que contiene los datos de una búsqueda
|
||||
public static $ldapSearchData;
|
||||
// Variable para determinar si conecta con Active Directory
|
||||
protected static $_isADS = false;
|
||||
protected static $_ADS = false;
|
||||
|
||||
// Variables de conexión con LDAP
|
||||
protected static $_ldapConn;
|
||||
@@ -253,9 +253,9 @@ class Ldap
|
||||
*/
|
||||
public static function checkLDAPParams()
|
||||
{
|
||||
self::$_isADS = Config::getValue('ldap_ads', false);
|
||||
self::$_ADS = Config::getValue('ldap_ads', false);
|
||||
self::$_searchBase = Config::getValue('ldap_base');
|
||||
self::$_ldapServer = (!self::$_isADS) ? Config::getValue('ldap_server') : LdapADS::getADServer(Config::getValue('ldap_server'));
|
||||
self::$_ldapServer = (!self::$_ADS) ? Config::getValue('ldap_server') : LdapADS::getADServer(Config::getValue('ldap_server'));
|
||||
self::$_bindDN = Config::getValue('ldap_binduser');
|
||||
self::$_bindPass = Config::getValue('ldap_bindpass');
|
||||
self::$_ldapGroup = Config::getValue('ldap_group', '*');
|
||||
@@ -280,7 +280,7 @@ class Ldap
|
||||
{
|
||||
$log = new Log(__FUNCTION__);
|
||||
|
||||
if (self::$_isADS === true) {
|
||||
if (self::$_ADS === true) {
|
||||
$filter = '(&(|(samaccountname=' . $userLogin . ')(cn=' . $userLogin . ')(uid=' . $userLogin . '))(|(objectClass=inetOrgPerson)(objectClass=person)(objectClass=simpleSecurityObject))(objectCategory=person))';
|
||||
} else {
|
||||
$filter = '(&(|(samaccountname=' . $userLogin . ')(cn=' . $userLogin . ')(uid=' . $userLogin . '))(|(objectClass=inetOrgPerson)(objectClass=person)(objectClass=simpleSecurityObject)))';
|
||||
@@ -431,4 +431,12 @@ class Ldap
|
||||
return preg_replace($chars, '\\\$1', $dn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isADS()
|
||||
{
|
||||
return self::$_ADS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class LdapADS extends Ldap
|
||||
*/
|
||||
public static function searchADUserInGroup($userLogin)
|
||||
{
|
||||
if (Ldap::$_isADS === false) {
|
||||
if (Ldap::$_ADS === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user