Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit faf4f21

Browse files
Merge pull request #70 from pajavyskocil/ldap_changes
Ldap changes
2 parents 24cc07e + 1509743 commit faf4f21

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
2020
#### Changed
2121
- RpcConnector now stores cookie into file
2222
- Set CONNECTTIMEOUT and TIMEOUT in RpcConnector
23+
- Use new object perunFacility in LDAP to search information about facility
2324

2425
## [v3.2.1]
2526
#### Fixed

lib/AdapterLdap.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class AdapterLdap extends Adapter
2929
const LDAP_PASSWORD = 'ldap.password';
3030
const LDAP_BASE = 'ldap.base';
3131

32-
private $ldapHostname;
33-
private $ldapUser;
34-
private $ldapPassword;
3532
private $ldapBase;
3633

3734
protected $connector;
@@ -44,13 +41,12 @@ public function __construct($configFileName = null)
4441

4542
$conf = Configuration::getConfig($configFileName);
4643

47-
$this->ldapHostname = $conf->getString(self::LDAP_HOSTNAME);
48-
$this->ldapUser = $conf->getString(self::LDAP_USER, null);
49-
$this->ldapPassword = $conf->getString(self::LDAP_PASSWORD, null);
44+
$ldapHostname = $conf->getString(self::LDAP_HOSTNAME);
45+
$ldapUser = $conf->getString(self::LDAP_USER, null);
46+
$ldapPassword = $conf->getString(self::LDAP_PASSWORD, null);
5047
$this->ldapBase = $conf->getString(self::LDAP_BASE);
5148

52-
53-
$this->connector = new LdapConnector($this->ldapHostname, $this->ldapUser, $this->ldapPassword);
49+
$this->connector = new LdapConnector($ldapHostname, $ldapUser, $ldapPassword);
5450
}
5551

5652
public function getPerunUser($idpEntityId, $uids)
@@ -122,9 +118,16 @@ public function getMemberGroups($user, $vo)
122118

123119
public function getSpGroups($spEntityId)
124120
{
121+
$facility = $this->connector->searchForEntity(
122+
$this->ldapBase,
123+
"(&(objectClass=perunFacility)(entityID=$spEntityId))",
124+
['perunFacilityId']
125+
);
126+
127+
$id = $facility['perunFacilityId'][0];
125128
$resources = $this->connector->searchForEntities(
126129
$this->ldapBase,
127-
"(&(objectClass=perunResource)(entityID=$spEntityId))",
130+
"(&(objectClass=perunResource)(perunFacilityDn=perunFacilityId=$id,$this->ldapBase))",
128131
["perunResourceId", "assignedGroupId", "perunVoId"]
129132
);
130133

@@ -274,9 +277,16 @@ public function setUserExtSourceAttributes($userExtSourceId, $attributes)
274277

275278
public function getUsersGroupsOnFacility($spEntityId, $userId)
276279
{
280+
$facility = $this->connector->searchForEntity(
281+
$this->ldapBase,
282+
"(&(objectClass=perunFacility)(entityID=$spEntityId))",
283+
['perunFacilityId']
284+
);
285+
286+
$id = $facility['perunFacilityId'][0];
277287
$resources = $this->connector->searchForEntities(
278288
$this->ldapBase,
279-
"(&(objectClass=perunResource)(entityID=$spEntityId))",
289+
"(&(objectClass=perunResource)(perunFacilityDn=perunFacilityId=$id,$this->ldapBase))",
280290
["perunResourceId"]
281291
);
282292
Logger::debug("Resources - " . var_export($resources, true));

0 commit comments

Comments
 (0)