/** * @brief Get a list of all users * @returns array with all uids * * Get a list of all users. */ public function getUsers() { if (is_null($this->_users)) { $ldap_users = OC_LDAP::fetchListOfUsers($this->ldapUserFilter, array(OC_LDAP::conf('ldapUserDisplayName'), 'dn')); $this->_users = OC_LDAP::ownCloudUserNames($ldap_users); } return $this->_users; }
/** * @brief get a list of all users in a group * @returns array with user ids */ public function usersInGroup($gid) { if (!$this->configured) { return array(); } if (isset($this->_group_users[$gid])) { return $this->_group_users[$gid]; } $groupDN = OC_LDAP::groupname2dn($gid); if (!$groupDN) { $this->_group_users[$gid] = array(); return array(); } $members = OC_LDAP::readAttribute($groupDN, $this->ldapGroupMemberAssocAttr); if (!$members) { $this->_group_users[$gid] = array(); return array(); } $result = array(); $isMemberUid = strtolower($this->ldapGroupMemberAssocAttr) == 'memberuid'; foreach ($members as $member) { if ($isMemberUid) { $filter = str_replace('%uid', $member, OC_LDAP::conf('ldapLoginFilter')); $ldap_users = OC_LDAP::fetchListOfUsers($filter, 'dn'); if (count($ldap_users) < 1) { continue; } $result[] = OC_LDAP::dn2username($ldap_users[0]); continue; } else { $result[] = OC_LDAP::dn2username($member); } } if (!$isMemberUid) { $result = array_intersect($result, OCP\User::getUsers()); } $this->_group_users[$gid] = array_unique($result, SORT_LOCALE_STRING); return $this->_group_users[$gid]; }