summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-12-20 16:09:04 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-12-20 16:09:04 +0100
commit144d95de7dde29cd85e795cdcd7ac1576639d641 (patch)
tree67de63f5c3c43b49cbb29cffcd6eb855eff68cb1 /apps/user_ldap/lib
parent4fa39250e714b3ee5aa16a5f9ce8c77daa44311b (diff)
downloadnextcloud-server-144d95de7dde29cd85e795cdcd7ac1576639d641.tar.gz
nextcloud-server-144d95de7dde29cd85e795cdcd7ac1576639d641.zip
basic adjustments for OC 8. I.e. no visible issues, LDAP tests pass.
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/access.php28
-rw-r--r--apps/user_ldap/lib/jobs.php3
-rw-r--r--apps/user_ldap/lib/user/deletedusersindex.php12
-rw-r--r--apps/user_ldap/lib/user/iusertools.php4
-rw-r--r--apps/user_ldap/lib/user/manager.php2
-rw-r--r--apps/user_ldap/lib/user/offlineuser.php12
6 files changed, 42 insertions, 19 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index 692afb98f99..3e9869b4d71 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -76,6 +76,18 @@ class Access extends LDAPUtility implements user\IUserTools {
}
/**
+ * returns the User Mapper
+ * @throws \Exception
+ * @return AbstractMapping
+ */
+ public function getUserMapper() {
+ if(is_null($this->userMapper)) {
+ throw new \Exception('UserMapper was not assigned to this Access instance.');
+ }
+ return $this->userMapper;
+ }
+
+ /**
* sets the Group Mapper
* @param AbstractMapping $mapper
*/
@@ -84,6 +96,18 @@ class Access extends LDAPUtility implements user\IUserTools {
}
/**
+ * returns the Group Mapper
+ * @throws \Exception
+ * @return AbstractMapping
+ */
+ public function getGroupMapper() {
+ if(is_null($this->groupMapper)) {
+ throw new \Exception('GroupMapper was not assigned to this Access instance.');
+ }
+ return $this->groupMapper;
+ }
+
+ /**
* @return bool
*/
private function checkConnection() {
@@ -333,10 +357,10 @@ class Access extends LDAPUtility implements user\IUserTools {
*/
public function dn2ocname($fdn, $ldapName = null, $isUser = true) {
if($isUser) {
- $mapper = $this->userMapper;
+ $mapper = $this->getUserMapper();
$nameAttribute = $this->connection->ldapUserDisplayName;
} else {
- $mapper = $this->groupMapper;
+ $mapper = $this->getGroupMapper();
$nameAttribute = $this->connection->ldapGroupDisplayName;
}
diff --git a/apps/user_ldap/lib/jobs.php b/apps/user_ldap/lib/jobs.php
index 30f09cdc8f8..391a10d31f8 100644
--- a/apps/user_ldap/lib/jobs.php
+++ b/apps/user_ldap/lib/jobs.php
@@ -23,6 +23,8 @@
namespace OCA\user_ldap\lib;
+use OCA\User_LDAP\Mapping\GroupMapping;
+
class Jobs extends \OC\BackgroundJob\TimedJob {
static private $groupsFromDB;
@@ -169,6 +171,7 @@ class Jobs extends \OC\BackgroundJob\TimedJob {
new \OCP\Image());
$connector = new Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new Access($connector, $ldapWrapper, $userManager);
+ $groupMapper = new GroupMapping(\OC::$server->getDatabaseConnection());
self::$groupBE = new \OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
self::$groupBE = new \OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
diff --git a/apps/user_ldap/lib/user/deletedusersindex.php b/apps/user_ldap/lib/user/deletedusersindex.php
index 0d8bacffe94..e544d29bad5 100644
--- a/apps/user_ldap/lib/user/deletedusersindex.php
+++ b/apps/user_ldap/lib/user/deletedusersindex.php
@@ -24,7 +24,7 @@
namespace OCA\user_ldap\lib\user;
use OCA\user_ldap\lib\user\OfflineUser;
-use OCA\user_ldap\lib\Access;
+use OCA\User_LDAP\Mapping\UserMapping;
/**
* Class DeletedUsersIndex
@@ -42,9 +42,9 @@ class DeletedUsersIndex {
protected $db;
/**
- * @var \OCA\user_ldap\lib\Access $access
+ * @var \OCA\User_LDAP\Mapping\UserMapping $mapping
*/
- protected $access;
+ protected $mapping;
/**
* @var int $limit
@@ -56,10 +56,10 @@ class DeletedUsersIndex {
*/
protected $deletedUsers = false;
- public function __construct(\OC\Preferences $preferences, \OCP\IDBConnection $db, Access $access) {
+ public function __construct(\OC\Preferences $preferences, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->preferences = $preferences;
$this->db = $db;
- $this->access = $access;
+ $this->mapping = $mapping;
}
/**
@@ -84,7 +84,7 @@ class DeletedUsersIndex {
$userObjects = array();
foreach($deletedUsers as $user) {
- $userObjects[] = new OfflineUser($user, $this->preferences, $this->db, $this->access);
+ $userObjects[] = new OfflineUser($user, $this->preferences, $this->db, $this->mapping);
}
$this->deletedUsers[$key] = $userObjects;
diff --git a/apps/user_ldap/lib/user/iusertools.php b/apps/user_ldap/lib/user/iusertools.php
index ffdef62410d..fcb00d2f746 100644
--- a/apps/user_ldap/lib/user/iusertools.php
+++ b/apps/user_ldap/lib/user/iusertools.php
@@ -38,8 +38,4 @@ interface IUserTools {
public function dn2username($dn, $ldapname = null);
public function username2dn($name);
-
- //temporary hack for LDAP user cleanup, will be removed in OC 8.
- public function ocname2dn($name, $isUser);
-
}
diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php
index 1bcc9b96d8a..cd4f4441e1d 100644
--- a/apps/user_ldap/lib/user/manager.php
+++ b/apps/user_ldap/lib/user/manager.php
@@ -154,7 +154,7 @@ class Manager {
$id,
new \OC\Preferences(\OC_DB::getConnection()),
\OC::$server->getDatabaseConnection(),
- $this->access);
+ $this->access->getUserMapper());
}
protected function createInstancyByUserName($id) {
diff --git a/apps/user_ldap/lib/user/offlineuser.php b/apps/user_ldap/lib/user/offlineuser.php
index 7750348a280..7cf48bc05b1 100644
--- a/apps/user_ldap/lib/user/offlineuser.php
+++ b/apps/user_ldap/lib/user/offlineuser.php
@@ -23,7 +23,7 @@
namespace OCA\user_ldap\lib\user;
-use OCA\user_ldap\lib\Access;
+use OCA\User_LDAP\Mapping\UserMapping;
class OfflineUser {
/**
@@ -67,15 +67,15 @@ class OfflineUser {
*/
protected $db;
/**
- * @var \OCA\user_ldap\lib\Access
+ * @var OCA\User_LDAP\Mapping\UserMapping
*/
- protected $access;
+ protected $mapping;
- public function __construct($ocName, \OC\Preferences $preferences, \OCP\IDBConnection $db, Access $access) {
+ public function __construct($ocName, \OC\Preferences $preferences, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->ocName = $ocName;
$this->preferences = $preferences;
$this->db = $db;
- $this->access = $access;
+ $this->mapping = $mapping;
$this->fetchDetails();
}
@@ -176,7 +176,7 @@ class OfflineUser {
$this->$property = $this->preferences->getValue($this->ocName, $app, $property, '');
}
- $dn = $this->access->ocname2dn($this->ocName, true);
+ $dn = $this->mapping->getDNByName($this->ocName);
$this->dn = ($dn !== false) ? $dn : '';
$this->determineShares();