 -            principalCollections = waitForDeferred(self.principalCollections(request))
 -            yield principalCollections
 -            principalCollections = principalCollections.getResult()
--
++            yield None
++            return
+ 
 -            if len(principalCollections) == 0:
 -                log.msg("DAV:principal-collection-set property cannot be found on the resource being authorized: %s" % self)
 -            else:
 -                log.msg("Could not find principal matching user id: %s" % authid)
 -            raise HTTPError(responsecode.FORBIDDEN)
-+            yield None
-+            return
- 
+-
      findPrincipalForAuthID = deferredGenerator(findPrincipalForAuthID)
  
 +    def authorizationPrincipal(self, request, authid, authnPrincipal, authnURI):

             It will errback with an HTTPError(responsecode.FORBIDDEN) if
             the principal isn't found.
         """
+
+        # Try to match principals in each principal collection on the resource
+        d = waitForDeferred(self.findPrincipalForAuthID(request, authid))
+        yield d
+        result = d.getResult()
+        
+        if result is not None:
+            authnPrincipal = result[0]
+            authnURI = result[1]
+            d = waitForDeferred(self.authorizationPrincipal(request, authid, authnPrincipal, authnURI))
+            yield d
+            authzPrincipal, authzURI = d.getResult()
+            yield ((authnPrincipal, authnURI), (authzPrincipal, authzURI),)
+            return
+        else:
+            principalCollections = waitForDeferred(self.principalCollections(request))
+            yield principalCollections
+            principalCollections = principalCollections.getResult()
+
+            if len(principalCollections) == 0:
+                log.msg("DAV:principal-collection-set property cannot be found on the resource being authorized: %s" % self)
+            else:
+                log.msg("Could not find principal matching user id: %s" % authid)
+            raise HTTPError(responsecode.FORBIDDEN)
+
+    principalsForAuthID = deferredGenerator(principalsForAuthID)
+
+    def findPrincipalForAuthID(self, request, authid):
+        """

 
         authHeader = request.headers.getHeader('authorization')
 
@@ -625,9 +682,11 @@
 
                 # Try to match principals in each principal collection on the resource
                 def gotDetails(details):
