summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/wizard.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-06-25 17:36:19 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-08-29 11:14:16 +0200
commit441c600c906a2ec55bdab123840be5d1d63bb679 (patch)
treed6880aa4c343d010e340761a0ba453de1eff06b9 /apps/user_ldap/lib/wizard.php
parentbaa49cd58a670ca7fdd9211cf057b2257d86eff9 (diff)
downloadnextcloud-server-441c600c906a2ec55bdab123840be5d1d63bb679.tar.gz
nextcloud-server-441c600c906a2ec55bdab123840be5d1d63bb679.zip
remove Access as hard dependency, inject it instead
Diffstat (limited to 'apps/user_ldap/lib/wizard.php')
-rw-r--r--apps/user_ldap/lib/wizard.php42
1 files changed, 10 insertions, 32 deletions
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php
index 9a7f7520f56..25dc4598ffb 100644
--- a/apps/user_ldap/lib/wizard.php
+++ b/apps/user_ldap/lib/wizard.php
@@ -25,6 +25,7 @@ namespace OCA\user_ldap\lib;
class Wizard extends LDAPUtility {
static protected $l;
+ protected $access;
protected $cr;
protected $configuration;
protected $result;
@@ -48,12 +49,13 @@ class Wizard extends LDAPUtility {
* @param Configuration $configuration an instance of Configuration
* @param ILDAPWrapper $ldap an instance of ILDAPWrapper
*/
- public function __construct(Configuration $configuration, ILDAPWrapper $ldap) {
+ public function __construct(Configuration $configuration, ILDAPWrapper $ldap, Access $access) {
parent::__construct($ldap);
$this->configuration = $configuration;
if(is_null(Wizard::$l)) {
Wizard::$l = \OC_L10N::get('user_ldap');
}
+ $this->access = $access;
$this->result = new WizardResult;
}
@@ -78,11 +80,10 @@ class Wizard extends LDAPUtility {
throw new \Exception('Requirements not met', 400);
}
- $ldapAccess = $this->getAccess();
if($type === 'groups') {
- $result = $ldapAccess->countGroups($filter);
+ $result = $this->access->countGroups($filter);
} else if($type === 'users') {
- $result = $ldapAccess->countUsers($filter);
+ $result = $this->access->countUsers($filter);
} else {
throw new \Exception('internal error: invald object type', 500);
}
@@ -142,13 +143,12 @@ class Wizard extends LDAPUtility {
return false;
}
- $access = $this->getAccess();
- $filter = $access->combineFilterWithAnd(array(
+ $filter = $this->access->combineFilterWithAnd(array(
$this->configuration->ldapUserFilter,
$attr . '=*'
));
- return $access->countUsers($filter);
+ return $this->access->countUsers($filter);
}
/**
@@ -352,7 +352,6 @@ class Wizard extends LDAPUtility {
*/
public function fetchGroups($dbKey, $confKey) {
$obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames');
- $ldapAccess = $this->getAccess();
$filterParts = array();
foreach($obclasses as $obclass) {
@@ -361,15 +360,15 @@ class Wizard extends LDAPUtility {
//we filter for everything
//- that looks like a group and
//- has the group display name set
- $filter = $ldapAccess->combineFilterWithOr($filterParts);
- $filter = $ldapAccess->combineFilterWithAnd(array($filter, 'cn=*'));
+ $filter = $this->access->combineFilterWithOr($filterParts);
+ $filter = $this->access->combineFilterWithAnd(array($filter, 'cn=*'));
$groupNames = array();
$groupEntries = array();
$limit = 400;
$offset = 0;
do {
- $result = $ldapAccess->searchGroups($filter, array('cn','dn'), $limit, $offset);
+ $result = $this->access->searchGroups($filter, array('cn'), $limit, $offset);
foreach($result as $item) {
$groupNames[] = $item['cn'];
$groupEntries[] = $item;
@@ -1169,27 +1168,6 @@ class Wizard extends LDAPUtility {
}
/**
- * creates and returns an Access instance
- * @return \OCA\user_ldap\lib\Access
- */
- private function getAccess() {
- $con = new Connection($this->ldap, '', null);
- $con->setConfiguration($this->configuration->getConfiguration());
- $con->ldapConfigurationActive = true;
- $con->setIgnoreValidation(true);
-
- $userManager = new user\Manager(
- \OC::$server->getConfig(),
- new FilesystemHelper(),
- new LogWrapper(),
- \OC::$server->getAvatarManager(),
- new \OCP\Image());
-
- $ldapAccess = new Access($con, $this->ldap, $userManager);
- return $ldapAccess;
- }
-
- /**
* @return bool|mixed
*/
private function getConnection() {