[CalendarServer-changes] [7036] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 17 14:14:53 PST 2011
Revision: 7036
http://trac.macosforge.org/projects/calendarserver/changeset/7036
Author: sagen at apple.com
Date: 2011-02-17 14:14:50 -0800 (Thu, 17 Feb 2011)
Log Message:
-----------
Allow configuration for which LDAP field calendar server uses for recordName (by type)
Modified Paths:
--------------
CalendarServer/trunk/conf/caldavd-test.plist
CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist 2011-02-17 21:42:20 UTC (rev 7035)
+++ CalendarServer/trunk/conf/caldavd-test.plist 2011-02-17 22:14:50 UTC (rev 7036)
@@ -249,6 +249,8 @@
<string></string>
<key>filter</key>
<string></string>
+ <key>recordName</key>
+ <string>uid</string>
</dict>
<key>groups</key>
<dict>
@@ -260,6 +262,8 @@
<string></string>
<key>filter</key>
<string></string>
+ <key>recordName</key>
+ <string>cn</string>
</dict>
<key>attributeMapping</key>
<dict>
Modified: CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-02-17 21:42:20 UTC (rev 7035)
+++ CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-02-17 22:14:50 UTC (rev 7036)
@@ -96,24 +96,28 @@
"attr": "uid", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "uid", # uniquely identifies user records
},
"groups": {
"rdn": "ou=Group",
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "cn", # uniquely identifies group records
},
"locations": {
"rdn": "ou=Locations",
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "cn", # uniquely identifies location records
},
"resources": {
"rdn": "ou=Resources",
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "cn", # uniquely identifies resource records
},
},
"groupSchema": {
@@ -401,8 +405,8 @@
emailAddresses.add(emailPrefix + emailSuffix)
# LDAP attribute -> principal matchings
+ shortNames = (self._getUniqueLdapAttribute(attrs, self.rdnSchema[recordType]["recordName"]),)
if recordType == self.recordType_users:
- shortNames = (self._getUniqueLdapAttribute(attrs, "uid", "userid"),)
fullName = self._getUniqueLdapAttribute(attrs, "cn", "commonName",
"displayName", "gecos")
firstName = self._getUniqueLdapAttribute(attrs, "givenName")
@@ -410,12 +414,10 @@
calendarUserAddresses = emailAddresses
enabledForCalendaring = True
elif recordType == self.recordType_groups:
- shortNames = (self._getUniqueLdapAttribute(attrs, "cn"),)
fullName = self._getUniqueLdapAttribute(attrs, "cn")
enabledForCalendaring = False
elif recordType in (self.recordType_resources,
self.recordType_locations):
- shortNames = (self._getUniqueLdapAttribute(attrs, "cn"),)
fullName = self._getUniqueLdapAttribute(attrs, "cn")
calendarUserAddresses = emailAddresses
enabledForCalendaring = True
@@ -482,12 +484,11 @@
filter = "(&%s(%s=%s))" % (filter, guidAttr, indexKey)
elif indexType == self.INDEX_TYPE_SHORTNAME:
- if recordType == self.recordType_users:
- filter = "(&%s(|(uid=%s)(userid=%s)))" % (
- filter, indexKey, indexKey)
- elif recordType in (self.recordType_groups,
- self.recordType_resources, self.recordType_locations):
- filter = "(&%s(cn=%s))" % (filter, indexKey)
+ filter = "(&%s(%s=%s))" % (
+ filter,
+ self.rdnSchema[recordType]["recordName"],
+ indexKey
+ )
elif indexType == self.INDEX_TYPE_CUA:
# indexKey is of the form "mailto:test at example.net"
@@ -740,16 +741,20 @@
),
)
self.log_debug("Finding groups containing %s" % (self._memberId,))
- results = self.service.ldap.search_s(ldap.dn.dn2str(base),
- ldap.SCOPE_SUBTREE, filter, self.service.attrList)
-
groups = []
- for dn, attrs in results:
- shortName = self.service._getUniqueLdapAttribute(attrs, "cn")
- self.log_debug("%s is a member of %s" % (self._memberId, shortName))
- groups.append(self.service.recordWithShortName(recordType,
- shortName))
+ try:
+ results = self.service.ldap.search_s(ldap.dn.dn2str(base),
+ ldap.SCOPE_SUBTREE, filter, self.service.attrList)
+
+ for dn, attrs in results:
+ shortName = self.service._getUniqueLdapAttribute(attrs, "cn")
+ self.log_debug("%s is a member of %s" % (self._memberId, shortName))
+ groups.append(self.service.recordWithShortName(recordType,
+ shortName))
+ except ldap.PROTOCOL_ERROR, e:
+ self.log_warn(str(e))
+
return groups
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2011-02-17 21:42:20 UTC (rev 7035)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2011-02-17 22:14:50 UTC (rev 7036)
@@ -75,24 +75,28 @@
"attr": "uid", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "userid", # uniquely identifies user records
},
"groups": {
"rdn": "ou=Group",
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "cn", # uniquely identifies group records
},
"locations": {
"rdn": "ou=Locations",
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "cn", # uniquely identifies location records
},
"resources": {
"rdn": "ou=Resources",
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "recordName": "cn", # uniquely identifies resource records
},
},
"groupSchema": {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110217/239076a4/attachment-0001.html>
More information about the calendarserver-changes
mailing list