[CalendarServer-changes] [7831] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 28 12:05:20 PDT 2011
Revision: 7831
http://trac.macosforge.org/projects/calendarserver/changeset/7831
Author: sagen at apple.com
Date: 2011-07-28 12:05:19 -0700 (Thu, 28 Jul 2011)
Log Message:
-----------
Adds support for controlling enabledForCalendaring via LDAP attribute.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
Modified: CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-07-28 15:06:19 UTC (rev 7830)
+++ CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-07-28 19:05:19 UTC (rev 7831)
@@ -103,7 +103,9 @@
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
"loginEnabledAttr" : "", # attribute controlling login
- "loginEnabledValue" : "yes", # value of above attribute
+ "loginEnabledValue" : "yes", # "True" value of above attribute
+ "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping" : { # maps internal record names to LDAP
"recordName": "uid",
"fullName" : "cn",
@@ -130,6 +132,8 @@
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping" : { # maps internal record names to LDAP
"recordName": "cn",
"fullName" : "cn",
@@ -143,6 +147,8 @@
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping" : { # maps internal record names to LDAP
"recordName": "cn",
"fullName" : "cn",
@@ -210,6 +216,8 @@
for recordType in self.recordTypes():
if self.rdnSchema[recordType]["attr"]:
attrSet.add(self.rdnSchema[recordType]["attr"])
+ if self.rdnSchema[recordType].get("calendarEnabledAttr", False):
+ attrSet.add(self.rdnSchema[recordType]["calendarEnabledAttr"])
for attr in self.rdnSchema[recordType]["mapping"].values():
if attr:
attrSet.add(attr)
@@ -669,6 +677,13 @@
record.enabledForLogin = self._getUniqueLdapAttribute(attrs,
loginEnabledAttr) == loginEnabledValue
+ # Override with LDAP calendar-enabled control if attribute specified
+ calendarEnabledAttr = self.rdnSchema[recordType].get("calendarEnabledAttr", "")
+ if calendarEnabledAttr:
+ calendarEnabledValue = self.rdnSchema[recordType]["calendarEnabledValue"]
+ record.enabledForCalendaring = self._getUniqueLdapAttribute(attrs,
+ calendarEnabledAttr) == calendarEnabledValue
+
return record
@@ -795,6 +810,13 @@
continue
record = self._ldapResultToRecord(dn, attrs, recordType)
+
+ # For non-group records, if not enabled for calendaring do
+ # not include in principal property search results
+ if (recordType != self.recordType_groups):
+ if not record.enabledForCalendaring:
+ continue
+
records.append(record)
self.log_debug("Principal property search matched %d records" % (len(records),))
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py 2011-07-28 15:06:19 UTC (rev 7830)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py 2011-07-28 19:05:19 UTC (rev 7831)
@@ -133,7 +133,9 @@
"emailSuffix": None, # used only to synthesize email address
"filter": "(objectClass=apple-user)", # additional filter for this type
"loginEnabledAttr" : "", # attribute controlling login
- "loginEnabledValue" : "yes", # value of above attribute
+ "loginEnabledValue" : "yes", # "True" value of above attribute
+ "calendarEnabledAttr" : "enable-calendar", # attribute controlling calendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping": { # maps internal record names to LDAP
"recordName": "uid",
"fullName" : "cn",
@@ -160,6 +162,8 @@
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": "(objectClass=apple-resource)", # additional filter for this type
+ "calendarEnabledAttr" : "", # attribute controlling calendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping": { # maps internal record names to LDAP
"recordName": "cn",
"fullName" : "cn",
@@ -173,6 +177,8 @@
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": "(objectClass=apple-resource)", # additional filter for this type
+ "calendarEnabledAttr" : "", # attribute controlling calendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping": { # maps internal record names to LDAP
"recordName": "cn",
"fullName" : "cn",
@@ -209,7 +215,7 @@
of LDAP attributes into an LdapDirectoryRecord
"""
- # User
+ # User without enabled-for-calendaring specified
dn = "uid=odtestamanda,cn=users,dc=example,dc=com"
guid = '9DC04A70-E6DD-11DF-9492-0800200C9A66'
@@ -233,7 +239,26 @@
self.assertEquals(record.lastName, 'Test')
self.assertEquals(record.serverID, None)
self.assertEquals(record.partitionID, None)
+ self.assertFalse(record.enabledForCalendaring)
+ # User with enabled-for-calendaring specified
+
+ dn = "uid=odtestamanda,cn=users,dc=example,dc=com"
+ guid = '9DC04A70-E6DD-11DF-9492-0800200C9A66'
+ attrs = {
+ 'uid': ['odtestamanda'],
+ 'apple-generateduid': [guid],
+ 'enable-calendar': ["yes"],
+ 'sn': ['Test'],
+ 'mail': ['odtestamanda at example.com', 'alternate at example.com'],
+ 'givenName': ['Amanda'],
+ 'cn': ['Amanda Test']
+ }
+
+ record = self.service._ldapResultToRecord(dn, attrs,
+ self.service.recordType_users)
+ self.assertTrue(record.enabledForCalendaring)
+
# User with "podding" info
dn = "uid=odtestamanda,cn=users,dc=example,dc=com"
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2011-07-28 15:06:19 UTC (rev 7830)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2011-07-28 19:05:19 UTC (rev 7831)
@@ -79,7 +79,9 @@
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
"loginEnabledAttr" : "", # attribute controlling login
- "loginEnabledValue" : "yes", # value of above attribute
+ "loginEnabledValue" : "yes", # "True" value of above attribute
+ "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping" : { # maps internal record names to LDAP
"recordName": "uid",
"fullName" : "cn",
@@ -106,6 +108,8 @@
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping" : { # maps internal record names to LDAP
"recordName": "cn",
"fullName" : "cn",
@@ -119,6 +123,8 @@
"attr": "cn", # used only to synthesize email address
"emailSuffix": None, # used only to synthesize email address
"filter": None, # additional filter for this type
+ "calendarEnabledAttr" : "", # attribute controlling enabledForCalendaring
+ "calendarEnabledValue" : "yes", # "True" value of above attribute
"mapping" : { # maps internal record names to LDAP
"recordName": "cn",
"fullName" : "cn",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110728/7b5e4538/attachment-0001.html>
More information about the calendarserver-changes
mailing list