/** * Returns a list of principals based on a prefix. * * This prefix will often contain something like 'principals'. You are only * expected to return principals that are in this base path. * * You are expected to return at least a 'uri' for every user, you can * return any additional properties if you wish so. Common properties are: * {DAV:}displayname * {http://sabredav.org/ns}email-address - This is a custom SabreDAV * field that's actualy injected in a number of other properties. If * you have an email address, use this property. * * @param string $prefixPath * @return array */ public function getPrincipalsByPrefix($prefixPath) { // This backend only support principals in one collection if ($prefixPath !== $this->prefix) { return array(); } $users = array(); $r = q("SELECT `nickname` FROM `user` WHERE `nickname` = '%s'", escape_tags($this->authBackend->getCurrentUser())); foreach ($r as $t) { $users[] = array('uri' => $this->prefix . '/' . strtolower($t['nickname']), '{DAV:}displayname' => $t['nickname']); } return $users; }
/** * Override function here. We want to cache authentication cookies * in the syncing client to avoid HTTP-401 roundtrips. * If the sync client supplies the cookies, then OC_User::isLoggedIn() * will return true and we can see this WebDAV request as already authenticated, * even if there are no HTTP Basic Auth headers. * In other case, just fallback to the parent implementation. * * @return bool */ public function authenticate(Sabre_DAV_Server $server, $realm) { if (OC_User::handleApacheAuth() || OC_User::isLoggedIn()) { $user = OC_User::getUser(); OC_Util::setupFS($user); $this->currentUser = $user; return true; } return parent::authenticate($server, $realm); }