Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 29aad73

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 2cd6990 + 4d3dc1f commit 29aad73

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

core/src/plugins/access.smb/smb.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function parse_url ($url)
6363
list ($pu['share'], $pu['path']) = (preg_match ('/^([^\/]+)\/(.*)/', $path, $regs))
6464
? array ($regs[1], preg_replace ('/\//', '\\', $regs[2]))
6565
: array ($path, '');
66+
if (empty($pu["path"]) && preg_match('/\/$/', $url)) $pu["path"] = "/";
6667
$pu['type'] = $pu['path'] ? 'path' : ($pu['share'] ? 'share' : ($pu['host'] ? 'host' : '**error**'));
6768
if (! ($pu['port'] = intval(@$pu['port']))) $pu['port'] = 139;
6869
/* $i = 0; $atcount = 0;

core/src/plugins/auth.ldap/class.ldapAuthDriver.php

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,15 +760,25 @@ public function updateUserObject(&$userObject)
760760
$userroles = $userObject->getRoles();
761761
//remove all mapped roles before
762762

763+
$userroles = $userObject->getRoles();
764+
//remove all mapped roles before
765+
766+
$oldRoles = array();
767+
$newRoles = array();
768+
763769
if (is_array($userroles)) {
764770
foreach ($userroles as $key => $role) {
765771
if ((AuthService::getRole($key)) && !(strpos($key, $this->mappedRolePrefix) === false)) {
766-
$userObject->removeRole($key);
772+
if (isSet($matchFilter) && !preg_match($matchFilter, $key)) continue;
773+
if (isSet($valueFilters) && !in_array($key, $valueFilters)) continue;
774+
//$userObject->removeRole($key);
775+
$oldRoles[$key] = $role;
767776
}
768777
}
769778
}
770-
$userObject->recomputeMergedRole();
779+
//$userObject->recomputeMergedRole();
771780

781+
// Detect changes
772782
foreach ($memberValues as $uniqValue => $fullDN) {
773783
$uniqValueWithPrefix = $rolePrefix . $uniqValue;
774784
if (isSet($matchFilter) && !preg_match($matchFilter, $uniqValueWithPrefix)) continue;
@@ -779,9 +789,30 @@ public function updateUserObject(&$userObject)
779789
$roleToAdd->setLabel($uniqValue);
780790
AuthService::updateRole($roleToAdd);
781791
}
782-
$userObject->addRole($roleToAdd);
792+
$newRoles[$roleToAdd->getId()] = $roleToAdd;
793+
//$userObject->addRole($roleToAdd);
794+
}
795+
796+
if((count(array_diff(array_keys($oldRoles), array_keys($newRoles))) > 0) ||
797+
(count(array_diff(array_keys($newRoles), array_keys($oldRoles))) > 0) )
798+
{
799+
// remove old roles
800+
foreach ($oldRoles as $key => $role) {
801+
if ((AuthService::getRole($key)) && !(strpos($key, $this->mappedRolePrefix) === false)) {
802+
$userObject->removeRole($key);
803+
}
804+
}
805+
806+
//Add new roles;
807+
foreach($newRoles as $key => $role){
808+
if ((AuthService::getRole($key)) && !(strpos($key, $this->mappedRolePrefix) === false)) {
809+
$userObject->addRole($role);
810+
}
811+
}
812+
$userObject->recomputeMergedRole();
783813
$changes = true;
784814
}
815+
785816
} else {
786817
foreach ($entry[$key] as $uniqValue) {
787818
if (isSet($matchFilter) && !preg_match($matchFilter, $uniqValue)) continue;

0 commit comments

Comments
 (0)