/** * @brief Check if the password is correct * @param $uid The username * @param $password The password * @returns true/false * * Check if the password is correct without logging in the user */ public function checkPassword($uid, $password) { //find out dn of the user name $filter = str_replace('%uid', $uid, OC_LDAP::conf('ldapLoginFilter')); $ldap_users = OC_LDAP::fetchListOfUsers($filter, 'dn'); if (count($ldap_users) < 1) { return false; } $dn = $ldap_users[0]; //are the credentials OK? if (!OC_LDAP::areCredentialsValid($dn, $password)) { return false; } //update some settings, if necessary $this->updateQuota($dn); $this->updateEmail($dn); //give back the display name return OC_LDAP::dn2username($dn); }
/** * @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]; }