[CalendarServer-changes] [361]
CalendarServer/trunk/twistedcaldav/directory
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 3 14:49:29 PST 2006
Revision: 361
http://trac.macosforge.org/projects/calendarserver/changeset/361
Author: wsanchez at apple.com
Date: 2006-11-03 14:49:28 -0800 (Fri, 03 Nov 2006)
Log Message:
-----------
Add userWithShortName() to IDirectoryService, implement in OpenDirectoryService.
Remove calendarUserAddresses attribute from IDirectoryRecord for now.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/cred.py
CalendarServer/trunk/twistedcaldav/directory/directory.py
CalendarServer/trunk/twistedcaldav/directory/idirectory.py
CalendarServer/trunk/twistedcaldav/directory/opendirectory.py
Modified: CalendarServer/trunk/twistedcaldav/directory/cred.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cred.py 2006-11-03 21:40:36 UTC (rev 360)
+++ CalendarServer/trunk/twistedcaldav/directory/cred.py 2006-11-03 22:49:28 UTC (rev 361)
@@ -45,7 +45,7 @@
# Try regular password check
return TwistedPropertyChecker.requestAvatarId(self, credentials)
- user = self.service.findUserWithShortName(credentials.credentials.username)
+ user = self.service.userWithShortName(credentials.credentials.username)
raise UnauthorizedLogin("Unknown credentials type for principal: %s" % (credentials.authnURI,))
if not user:
Modified: CalendarServer/trunk/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/directory.py 2006-11-03 21:40:36 UTC (rev 360)
+++ CalendarServer/trunk/twistedcaldav/directory/directory.py 2006-11-03 22:49:28 UTC (rev 361)
@@ -34,13 +34,12 @@
class DirectoryRecord(object):
implements(IDirectoryRecord)
- def __init__(self, directory, recordType, guid, shortName, fullName=None, calendarUserAddresses=()):
- self.directory = directory
- self.recordType = recordType
- self.guid = guid
- self.shortName = shortName
- self.fullName = fullName
- self.calendarUserAddresses = calendarUserAddresses
+ def __init__(self, directory, recordType, guid, shortName, fullName=None):
+ self.directory = directory
+ self.recordType = recordType
+ self.guid = guid
+ self.shortName = shortName
+ self.fullName = fullName
def authenticate(credentials):
return False
Modified: CalendarServer/trunk/twistedcaldav/directory/idirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/idirectory.py 2006-11-03 21:40:36 UTC (rev 360)
+++ CalendarServer/trunk/twistedcaldav/directory/idirectory.py 2006-11-03 22:49:28 UTC (rev 361)
@@ -37,22 +37,28 @@
in the directory. For example: C{["users", "groups", "resources"]}.
"""
- def listRecords(type):
+ def listRecords(recordType):
"""
@param type: the type of records to retrieve.
@return: an iterable of records of the given type.
"""
+ def userWithShortName(shortName):
+ """
+ @param short_name: the short name of the user to look up.
+ @return: an L{IDirectoryRecord} provider with the given short name, or
+ C{None} of no such user exists.
+ """
+
class IDirectoryRecord(Interface):
"""
Directory Record
"""
- directory = Attribute("The L{IDirectoryService} this record exists in.")
- recordType = Attribute("The type of this record.")
- guid = Attribute("The GUID of this record.")
- shortName = Attribute("The name of this record.")
- fullName = Attribute("The full name of this record.")
- calendarUserAddresses = Attribute("A sequence of calendar user addresses of this record.")
+ directory Attribute("The L{IDirectoryService} this record exists in.")
+ recordType Attribute("The type of this record.")
+ guid Attribute("The GUID of this record.")
+ shortName Attribute("The name of this record.")
+ fullName Attribute("The full name of this record.")
def authenticate(credentials):
"""
Modified: CalendarServer/trunk/twistedcaldav/directory/opendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/opendirectory.py 2006-11-03 21:40:36 UTC (rev 360)
+++ CalendarServer/trunk/twistedcaldav/directory/opendirectory.py 2006-11-03 22:49:28 UTC (rev 361)
@@ -61,7 +61,6 @@
guid = guid,
shortName = shortName,
fullName = None,
- calendarUserAddresses = (),
)
if recordType == "users":
@@ -81,6 +80,20 @@
raise AssertionError("Unknown Open Directory record type: %s" % (recordType,))
+ def userWithShortName(shortName):
+ result = opendirectory.listUsersWithAttributes(self._directory, [shortName])
+ if shortName not in result:
+ return None
+ result = result[shortName]
+
+ return OpenDirectoryRecord(
+ directory = self,
+ recordType = "user",
+ guid = result[dsattributes.attrGUID],
+ shortName = shortName,
+ fullName = result[dsattributes.attrRealName],
+ )
+
class OpenDirectoryRecord(DirectoryRecord):
"""
Open Directory implementation of L{IDirectoryRecord}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061103/f5392316/attachment.html
More information about the calendarserver-changes
mailing list