diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2012-07-20 17:43:44 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2012-07-25 12:56:08 +0200 |
commit | 42492338fc708a09ada3d4ef6f4cc8aa0c670ee3 (patch) | |
tree | 53d7677816b9000fffc037f658ddd2ffe2a61072 /apps/user_ldap/group_ldap.php | |
parent | 57c375ea245d57567316254df2968b5b929733a7 (diff) | |
download | nextcloud-server-42492338fc708a09ada3d4ef6f4cc8aa0c670ee3.tar.gz nextcloud-server-42492338fc708a09ada3d4ef6f4cc8aa0c670ee3.zip |
LDAP: put app under the OCA\user_ldap\ namespace
Diffstat (limited to 'apps/user_ldap/group_ldap.php')
-rw-r--r-- | apps/user_ldap/group_ldap.php | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index d438c7d84df..06db535490a 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -21,7 +21,9 @@ * */ -class OC_GROUP_LDAP extends OC_Group_Backend { +namespace OCA\user_ldap; + +class GROUP_LDAP extends \OC_Group_Backend { // //group specific settings protected $ldapGroupFilter; protected $ldapGroupMemberAssocAttr; @@ -33,8 +35,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { protected $_groups = array(); public function __construct() { - $this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)'); - $this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'); + $this->ldapGroupFilter = \OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)'); + $this->ldapGroupMemberAssocAttr = \OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'); if(!empty($this->ldapGroupFilter) && !empty($this->ldapGroupMemberAssocAttr)) { $this->configured = true; @@ -56,14 +58,14 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(isset($this->_group_user[$gid][$uid])) { return $this->_group_user[$gid][$uid]; } - $dn_user = OC_LDAP::username2dn($uid); - $dn_group = OC_LDAP::groupname2dn($gid); + $dn_user = \OC_LDAP::username2dn($uid); + $dn_group = \OC_LDAP::groupname2dn($gid); // just in case if(!$dn_group || !$dn_user) { return false; } //usually, LDAP attributes are said to be case insensitive. But there are exceptions of course. - $members = OC_LDAP::readAttribute($dn_group, $this->ldapGroupMemberAssocAttr); + $members = \OC_LDAP::readAttribute($dn_group, $this->ldapGroupMemberAssocAttr); if(!$members) { return false; } @@ -73,8 +75,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(strtolower($this->ldapGroupMemberAssocAttr) == 'memberuid') { $dns = array(); foreach($members as $mid) { - $filter = str_replace('%uid', $mid, OC_LDAP::conf('ldapLoginFilter')); - $ldap_users = OC_LDAP::fetchListOfUsers($filter, 'dn'); + $filter = str_replace('%uid', $mid, \OC_LDAP::conf('ldapLoginFilter')); + $ldap_users = \OC_LDAP::fetchListOfUsers($filter, 'dn'); if(count($ldap_users) < 1) { continue; } @@ -102,7 +104,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend { if(isset($this->_user_groups[$uid])) { return $this->_user_groups[$uid]; } - $userDN = OC_LDAP::username2dn($uid); + $userDN = \OC_LDAP::username2dn($uid); if(!$userDN) { $this->_user_groups[$uid] = array(); return array(); @@ -113,19 +115,19 @@ class OC_GROUP_LDAP extends OC_Group_Backend { || (strtolower($this->ldapGroupMemberAssocAttr) == 'member')) { $uid = $userDN; } else if(strtolower($this->ldapGroupMemberAssocAttr) == 'memberuid') { - $result = OC_LDAP::readAttribute($userDN, 'uid'); + $result = \OC_LDAP::readAttribute($userDN, 'uid'); $uid = $result[0]; } else { // just in case $uid = $userDN; } - $filter = OC_LDAP::combineFilterWithAnd(array( + $filter = \OC_LDAP::combineFilterWithAnd(array( $this->ldapGroupFilter, $this->ldapGroupMemberAssocAttr.'='.$uid )); - $groups = OC_LDAP::fetchListOfGroups($filter, array(OC_LDAP::conf('ldapGroupDisplayName'),'dn')); - $this->_user_groups[$uid] = array_unique(OC_LDAP::ownCloudGroupNames($groups), SORT_LOCALE_STRING); + $groups = \OC_LDAP::fetchListOfGroups($filter, array(\OC_LDAP::conf('ldapGroupDisplayName'),'dn')); + $this->_user_groups[$uid] = array_unique(\OC_LDAP::ownCloudGroupNames($groups), SORT_LOCALE_STRING); return $this->_user_groups[$uid]; } @@ -142,13 +144,13 @@ class OC_GROUP_LDAP extends OC_Group_Backend { return $this->_group_users[$gid]; } - $groupDN = OC_LDAP::groupname2dn($gid); + $groupDN = \OC_LDAP::groupname2dn($gid); if(!$groupDN) { $this->_group_users[$gid] = array(); return array(); } - $members = OC_LDAP::readAttribute($groupDN, $this->ldapGroupMemberAssocAttr); + $members = \OC_LDAP::readAttribute($groupDN, $this->ldapGroupMemberAssocAttr); if(!$members) { $this->_group_users[$gid] = array(); return array(); @@ -158,21 +160,21 @@ class OC_GROUP_LDAP extends OC_Group_Backend { $isMemberUid = (strtolower($this->ldapGroupMemberAssocAttr) == 'memberuid'); foreach($members as $member) { if($isMemberUid) { - $filter = OCP\Util::mb_str_replace('%uid', $member, OC_LDAP::conf('ldapLoginFilter'), 'UTF-8'); - $ldap_users = OC_LDAP::fetchListOfUsers($filter, 'dn'); + $filter = \OCP\Util::mb_str_replace('%uid', $member, \OC_LDAP::conf('ldapLoginFilter'), 'UTF-8'); + $ldap_users = \OC_LDAP::fetchListOfUsers($filter, 'dn'); if(count($ldap_users) < 1) { continue; } - $result[] = OC_LDAP::dn2username($ldap_users[0]); + $result[] = \OC_LDAP::dn2username($ldap_users[0]); continue; } else { - if($ocname = OC_LDAP::dn2username($member)){ + if($ocname = \OC_LDAP::dn2username($member)){ $result[] = $ocname; } } } if(!$isMemberUid) { - $result = array_intersect($result, OCP\User::getUsers()); + $result = array_intersect($result, \OCP\User::getUsers()); } $this->_group_users[$gid] = array_unique($result, SORT_LOCALE_STRING); return $this->_group_users[$gid]; @@ -189,8 +191,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { return array(); } if(empty($this->_groups)) { - $ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn')); - $this->_groups = OC_LDAP::ownCloudGroupNames($ldap_groups); + $ldap_groups = \OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(\OC_LDAP::conf('ldapGroupDisplayName'), 'dn')); + $this->_groups = \OC_LDAP::ownCloudGroupNames($ldap_groups); } return $this->_groups; } |