<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12087] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12087">12087</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2013-12-13 13:51:30 -0800 (Fri, 13 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>LDAP support for structured locations</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkconfcaldavdtestplist">CalendarServer/trunk/conf/caldavd-test.plist</a></li>
<li><a href="#CalendarServertrunktwistedcaldavdirectoryldapdirectorypy">CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavdirectorytesttest_ldapdirectorypy">CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkconfcaldavdtestplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/caldavd-test.plist (12086 => 12087)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/caldavd-test.plist        2013-12-13 18:21:26 UTC (rev 12086)
+++ CalendarServer/trunk/conf/caldavd-test.plist        2013-12-13 21:51:30 UTC (rev 12087)
</span><span class="lines">@@ -284,29 +284,20 @@
</span><span class="cx">                     &lt;string&gt;mail&lt;/string&gt;
</span><span class="cx">                     &lt;string&gt;mailAlias&lt;/string&gt;
</span><span class="cx">                 &lt;/array&gt;
</span><del>-                &lt;key&gt;firstName&lt;/key&gt;
-                &lt;string&gt;&lt;/string&gt;
-                &lt;key&gt;lastName&lt;/key&gt;
-                &lt;string&gt;&lt;/string&gt;
</del><span class="cx">             &lt;/dict&gt;
</span><span class="cx">           &lt;/dict&gt;
</span><span class="cx">           &lt;key&gt;locations&lt;/key&gt;
</span><span class="cx">           &lt;dict&gt;
</span><span class="cx">             &lt;key&gt;rdn&lt;/key&gt;
</span><span class="cx">             &lt;string&gt;ou=locations&lt;/string&gt;
</span><ins>+            &lt;key&gt;associatedAddressAttr&lt;/key&gt;
+            &lt;string&gt;&lt;/string&gt;
</ins><span class="cx">             &lt;key&gt;mapping&lt;/key&gt;
</span><span class="cx">             &lt;dict&gt;
</span><span class="cx">                 &lt;key&gt;recordName&lt;/key&gt;
</span><span class="cx">                 &lt;string&gt;cn&lt;/string&gt;
</span><span class="cx">                 &lt;key&gt;fullName&lt;/key&gt;
</span><span class="cx">                 &lt;string&gt;cn&lt;/string&gt;
</span><del>-                &lt;key&gt;emailAddresses&lt;/key&gt;
-                &lt;array&gt;
-                &lt;/array&gt;
-                &lt;key&gt;firstName&lt;/key&gt;
-                &lt;string&gt;&lt;/string&gt;
-                &lt;key&gt;lastName&lt;/key&gt;
-                &lt;string&gt;&lt;/string&gt;
</del><span class="cx">             &lt;/dict&gt;
</span><span class="cx">           &lt;/dict&gt;
</span><span class="cx">           &lt;key&gt;resources&lt;/key&gt;
</span><span class="lines">@@ -319,15 +310,24 @@
</span><span class="cx">                 &lt;string&gt;cn&lt;/string&gt;
</span><span class="cx">                 &lt;key&gt;fullName&lt;/key&gt;
</span><span class="cx">                 &lt;string&gt;cn&lt;/string&gt;
</span><del>-                &lt;key&gt;emailAddresses&lt;/key&gt;
-                &lt;array&gt;
-                &lt;/array&gt;
-                &lt;key&gt;firstName&lt;/key&gt;
-                &lt;string&gt;&lt;/string&gt;
-                &lt;key&gt;lastName&lt;/key&gt;
-                &lt;string&gt;&lt;/string&gt;
</del><span class="cx">             &lt;/dict&gt;
</span><span class="cx">           &lt;/dict&gt;
</span><ins>+          &lt;key&gt;addresses&lt;/key&gt;
+          &lt;dict&gt;
+            &lt;key&gt;rdn&lt;/key&gt;
+            &lt;string&gt;ou=buildings&lt;/string&gt;
+            &lt;key&gt;geoAttr&lt;/key&gt;
+            &lt;string&gt;&lt;/string&gt;
+            &lt;key&gt;streetAddressAttr&lt;/key&gt;
+            &lt;string&gt;&lt;/string&gt;
+            &lt;key&gt;mapping&lt;/key&gt;
+            &lt;dict&gt;
+                &lt;key&gt;recordName&lt;/key&gt;
+                &lt;string&gt;cn&lt;/string&gt;
+                &lt;key&gt;fullName&lt;/key&gt;
+                &lt;string&gt;cn&lt;/string&gt;
+            &lt;/dict&gt;
+          &lt;/dict&gt;
</ins><span class="cx">         &lt;/dict&gt;
</span><span class="cx">         &lt;key&gt;groupSchema&lt;/key&gt;
</span><span class="cx">         &lt;dict&gt;
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavdirectoryldapdirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py (12086 => 12087)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py        2013-12-13 18:21:26 UTC (rev 12086)
+++ CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py        2013-12-13 21:51:30 UTC (rev 12087)
</span><span class="lines">@@ -113,8 +113,6 @@
</span><span class="cx">                 &quot;guidAttr&quot;: &quot;entryUUID&quot;,
</span><span class="cx">                 &quot;users&quot;: {
</span><span class="cx">                     &quot;rdn&quot;: &quot;ou=People&quot;,
</span><del>-                    &quot;attr&quot;: &quot;uid&quot;, # used only to synthesize email address
-                    &quot;emailSuffix&quot;: None, # used only to synthesize email address
</del><span class="cx">                     &quot;filter&quot;: None, # additional filter for this type
</span><span class="cx">                     &quot;loginEnabledAttr&quot; : &quot;&quot;, # attribute controlling login
</span><span class="cx">                     &quot;loginEnabledValue&quot; : &quot;yes&quot;, # &quot;True&quot; value of above attribute
</span><span class="lines">@@ -130,8 +128,6 @@
</span><span class="cx">                 },
</span><span class="cx">                 &quot;groups&quot;: {
</span><span class="cx">                     &quot;rdn&quot;: &quot;ou=Group&quot;,
</span><del>-                    &quot;attr&quot;: &quot;cn&quot;, # used only to synthesize email address
-                    &quot;emailSuffix&quot;: None, # used only to synthesize email address
</del><span class="cx">                     &quot;filter&quot;: None, # additional filter for this type
</span><span class="cx">                     &quot;mapping&quot; : { # maps internal record names to LDAP
</span><span class="cx">                         &quot;recordName&quot;: &quot;cn&quot;,
</span><span class="lines">@@ -143,23 +139,18 @@
</span><span class="cx">                 },
</span><span class="cx">                 &quot;locations&quot;: {
</span><span class="cx">                     &quot;rdn&quot;: &quot;ou=Places&quot;,
</span><del>-                    &quot;attr&quot;: &quot;cn&quot;, # used only to synthesize email address
-                    &quot;emailSuffix&quot;: None, # used only to synthesize email address
</del><span class="cx">                     &quot;filter&quot;: None, # additional filter for this type
</span><span class="cx">                     &quot;calendarEnabledAttr&quot; : &quot;&quot;, # attribute controlling enabledForCalendaring
</span><span class="cx">                     &quot;calendarEnabledValue&quot; : &quot;yes&quot;, # &quot;True&quot; value of above attribute
</span><ins>+                    &quot;associatedAddressAttr&quot; : &quot;&quot;,
</ins><span class="cx">                     &quot;mapping&quot; : { # maps internal record names to LDAP
</span><span class="cx">                         &quot;recordName&quot;: &quot;cn&quot;,
</span><span class="cx">                         &quot;fullName&quot; : &quot;cn&quot;,
</span><span class="cx">                         &quot;emailAddresses&quot; : [&quot;mail&quot;], # multiple LDAP fields supported
</span><del>-                        &quot;firstName&quot; : &quot;givenName&quot;,
-                        &quot;lastName&quot; : &quot;sn&quot;,
</del><span class="cx">                     },
</span><span class="cx">                 },
</span><span class="cx">                 &quot;resources&quot;: {
</span><span class="cx">                     &quot;rdn&quot;: &quot;ou=Resources&quot;,
</span><del>-                    &quot;attr&quot;: &quot;cn&quot;, # used only to synthesize email address
-                    &quot;emailSuffix&quot;: None, # used only to synthesize email address
</del><span class="cx">                     &quot;filter&quot;: None, # additional filter for this type
</span><span class="cx">                     &quot;calendarEnabledAttr&quot; : &quot;&quot;, # attribute controlling enabledForCalendaring
</span><span class="cx">                     &quot;calendarEnabledValue&quot; : &quot;yes&quot;, # &quot;True&quot; value of above attribute
</span><span class="lines">@@ -167,10 +158,18 @@
</span><span class="cx">                         &quot;recordName&quot;: &quot;cn&quot;,
</span><span class="cx">                         &quot;fullName&quot; : &quot;cn&quot;,
</span><span class="cx">                         &quot;emailAddresses&quot; : [&quot;mail&quot;], # multiple LDAP fields supported
</span><del>-                        &quot;firstName&quot; : &quot;givenName&quot;,
-                        &quot;lastName&quot; : &quot;sn&quot;,
</del><span class="cx">                     },
</span><span class="cx">                 },
</span><ins>+                &quot;addresses&quot;: {
+                    &quot;rdn&quot;: &quot;ou=Buildings&quot;,
+                    &quot;filter&quot;: None, # additional filter for this type
+                    &quot;streetAddressAttr&quot; : &quot;&quot;,
+                    &quot;geoAttr&quot; : &quot;&quot;,
+                    &quot;mapping&quot; : { # maps internal record names to LDAP
+                        &quot;recordName&quot;: &quot;cn&quot;,
+                        &quot;fullName&quot; : &quot;cn&quot;,
+                    },
+                },
</ins><span class="cx">             },
</span><span class="cx">             &quot;groupSchema&quot;: {
</span><span class="cx">                 &quot;membersAttr&quot;: &quot;member&quot;, # how members are specified
</span><span class="lines">@@ -238,8 +237,10 @@
</span><span class="cx">         for recordType in self.recordTypes():
</span><span class="cx">             if self.rdnSchema[recordType][&quot;attr&quot;]:
</span><span class="cx">                 attrSet.add(self.rdnSchema[recordType][&quot;attr&quot;])
</span><del>-            if self.rdnSchema[recordType].get(&quot;calendarEnabledAttr&quot;, False):
-                attrSet.add(self.rdnSchema[recordType][&quot;calendarEnabledAttr&quot;])
</del><ins>+            for n in (&quot;calendarEnabledAttr&quot;, &quot;associatedAddressAttr&quot;,
+                &quot;streetAddressAttr&quot;, &quot;geoAttr&quot;):
+                if self.rdnSchema[recordType].get(n, False):
+                    attrSet.add(self.rdnSchema[recordType][n])
</ins><span class="cx">             for attrList in self.rdnSchema[recordType][&quot;mapping&quot;].values():
</span><span class="cx">                 if attrList:
</span><span class="cx">                     # Since emailAddresses can map to multiple LDAP fields,
</span><span class="lines">@@ -304,7 +305,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Build filter
</span><span class="cx">         filterstr = &quot;(!(objectClass=organizationalUnit))&quot;
</span><del>-        typeFilter = self.rdnSchema[recordType][&quot;filter&quot;]
</del><ins>+        typeFilter = self.rdnSchema[recordType].get(&quot;filter&quot;, &quot;&quot;)
</ins><span class="cx">         if typeFilter:
</span><span class="cx">             filterstr = &quot;(&amp;%s%s)&quot; % (filterstr, typeFilter)
</span><span class="cx"> 
</span><span class="lines">@@ -778,6 +779,7 @@
</span><span class="cx">         enabledForAddressBooks = None
</span><span class="cx">         uid = None
</span><span class="cx">         enabledForLogin = True
</span><ins>+        extras = {}
</ins><span class="cx"> 
</span><span class="cx">         shortNames = tuple(self._getMultipleLdapAttributes(attrs, self.rdnSchema[recordType][&quot;mapping&quot;][&quot;recordName&quot;]))
</span><span class="cx">         if not shortNames:
</span><span class="lines">@@ -794,17 +796,17 @@
</span><span class="cx"> 
</span><span class="cx">         # Find or build email
</span><span class="cx">         # (The emailAddresses mapping is a list of ldap fields)
</span><del>-        emailAddressesMappedTo = self.rdnSchema[recordType][&quot;mapping&quot;][&quot;emailAddresses&quot;]
</del><ins>+        emailAddressesMappedTo = self.rdnSchema[recordType][&quot;mapping&quot;].get(&quot;emailAddresses&quot;, &quot;&quot;)
</ins><span class="cx">         # Supporting either string or list for emailAddresses:
</span><span class="cx">         if isinstance(emailAddressesMappedTo, str):
</span><del>-            emailAddresses = set(self._getMultipleLdapAttributes(attrs, self.rdnSchema[recordType][&quot;mapping&quot;][&quot;emailAddresses&quot;]))
</del><ins>+            emailAddresses = set(self._getMultipleLdapAttributes(attrs, self.rdnSchema[recordType][&quot;mapping&quot;].get(&quot;emailAddresses&quot;, &quot;&quot;)))
</ins><span class="cx">         else:
</span><span class="cx">             emailAddresses = set(self._getMultipleLdapAttributes(attrs, *self.rdnSchema[recordType][&quot;mapping&quot;][&quot;emailAddresses&quot;]))
</span><del>-        emailSuffix = self.rdnSchema[recordType][&quot;emailSuffix&quot;]
</del><ins>+        emailSuffix = self.rdnSchema[recordType].get(&quot;emailSuffix&quot;, None)
</ins><span class="cx"> 
</span><span class="cx">         if len(emailAddresses) == 0 and emailSuffix:
</span><span class="cx">             emailPrefix = self._getUniqueLdapAttribute(attrs,
</span><del>-                self.rdnSchema[recordType][&quot;attr&quot;])
</del><ins>+                self.rdnSchema[recordType].get(&quot;attr&quot;, &quot;cn&quot;))
</ins><span class="cx">             emailAddresses.add(emailPrefix + emailSuffix)
</span><span class="cx"> 
</span><span class="cx">         proxyGUIDs = ()
</span><span class="lines">@@ -890,6 +892,25 @@
</span><span class="cx">                     autoAcceptGroup = self._getUniqueLdapAttribute(attrs,
</span><span class="cx">                         self.resourceSchema[&quot;autoAcceptGroupAttr&quot;])
</span><span class="cx"> 
</span><ins>+            if recordType == self.recordType_locations:
+                if self.rdnSchema[recordType][&quot;associatedAddressAttr&quot;]:
+                    associatedAddress = self._getUniqueLdapAttribute(attrs,
+                        self.rdnSchema[recordType][&quot;associatedAddressAttr&quot;])
+                    if associatedAddress:
+                        extras[&quot;associatedAddress&quot;] = associatedAddress
+
+        elif recordType == self.recordType_addresses:
+            if self.rdnSchema[recordType].get(&quot;geoAttr&quot;, &quot;&quot;):
+                geo = self._getUniqueLdapAttribute(attrs,
+                    self.rdnSchema[recordType][&quot;geoAttr&quot;])
+                if geo:
+                    extras[&quot;geo&quot;] = geo
+            if self.rdnSchema[recordType].get(&quot;streetAddressAttr&quot;, &quot;&quot;):
+                street = self._getUniqueLdapAttribute(attrs,
+                    self.rdnSchema[recordType][&quot;streetAddressAttr&quot;])
+                if street:
+                    extras[&quot;streetAddress&quot;] = street
+
</ins><span class="cx">         serverID = None
</span><span class="cx">         if self.poddingSchema[&quot;serverIdAttr&quot;]:
</span><span class="cx">             serverID = self._getUniqueLdapAttribute(attrs,
</span><span class="lines">@@ -911,6 +932,7 @@
</span><span class="cx">             extProxies=proxyGUIDs,
</span><span class="cx">             extReadOnlyProxies=readOnlyProxyGUIDs,
</span><span class="cx">             attrs=attrs,
</span><ins>+            **extras
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         if self.augmentService is not None:
</span><span class="lines">@@ -981,7 +1003,7 @@
</span><span class="cx"> 
</span><span class="cx">             # Build filter
</span><span class="cx">             filterstr = &quot;(!(objectClass=organizationalUnit))&quot;
</span><del>-            typeFilter = self.rdnSchema[recordType][&quot;filter&quot;]
</del><ins>+            typeFilter = self.rdnSchema[recordType].get(&quot;filter&quot;, &quot;&quot;)
</ins><span class="cx">             if typeFilter:
</span><span class="cx">                 filterstr = &quot;(&amp;%s%s)&quot; % (filterstr, typeFilter)
</span><span class="cx"> 
</span><span class="lines">@@ -1003,17 +1025,17 @@
</span><span class="cx">             elif indexType == self.INDEX_TYPE_CUA:
</span><span class="cx">                 # indexKey is of the form &quot;mailto:test@example.net&quot;
</span><span class="cx">                 email = indexKey[7:] # strip &quot;mailto:&quot;
</span><del>-                emailSuffix = self.rdnSchema[recordType][&quot;emailSuffix&quot;]
</del><ins>+                emailSuffix = self.rdnSchema[recordType].get(&quot;emailSuffix&quot;, None)
</ins><span class="cx">                 if emailSuffix is not None and email.partition(&quot;@&quot;)[2] == emailSuffix:
</span><span class="cx">                     filterstr = &quot;(&amp;%s(|(&amp;(!(mail=*))(%s=%s))(mail=%s)))&quot; % (
</span><span class="cx">                         filterstr,
</span><del>-                        self.rdnSchema[recordType][&quot;attr&quot;],
</del><ins>+                        self.rdnSchema[recordType].get(&quot;attr&quot;, &quot;cn&quot;),
</ins><span class="cx">                         email.partition(&quot;@&quot;)[0],
</span><span class="cx">                         ldapEsc(email)
</span><span class="cx">                     )
</span><span class="cx">                 else:
</span><span class="cx">                     # emailAddresses can map to multiple LDAP fields
</span><del>-                    ldapFields = self.rdnSchema[recordType][&quot;mapping&quot;][&quot;emailAddresses&quot;]
</del><ins>+                    ldapFields = self.rdnSchema[recordType][&quot;mapping&quot;].get(&quot;emailAddresses&quot;, &quot;&quot;)
</ins><span class="cx">                     if isinstance(ldapFields, str):
</span><span class="cx">                         if ldapFields:
</span><span class="cx">                             subfilter = &quot;(%s=%s)&quot; % (ldapFields, ldapEsc(email))
</span><span class="lines">@@ -1108,7 +1130,7 @@
</span><span class="cx">             typeCounts[recordType] = 0
</span><span class="cx">             base = self.typeDNs[recordType]
</span><span class="cx">             scope = ldap.SCOPE_SUBTREE
</span><del>-            extraFilter = self.rdnSchema[recordType][&quot;filter&quot;]
</del><ins>+            extraFilter = self.rdnSchema[recordType].get(&quot;filter&quot;, &quot;&quot;)
</ins><span class="cx">             filterstr = buildFilterFromTokens(recordType, self.rdnSchema[recordType][&quot;mapping&quot;],
</span><span class="cx">                 tokens, extra=extraFilter)
</span><span class="cx"> 
</span><span class="lines">@@ -1509,7 +1531,7 @@
</span><span class="cx">         guid, shortNames, authIDs, fullName,
</span><span class="cx">         firstName, lastName, emailAddresses,
</span><span class="cx">         uid, dn, memberGUIDs, extProxies, extReadOnlyProxies,
</span><del>-        attrs
</del><ins>+        attrs, **kwargs
</ins><span class="cx">     ):
</span><span class="cx">         super(LdapDirectoryRecord, self).__init__(
</span><span class="cx">             service=service,
</span><span class="lines">@@ -1524,6 +1546,7 @@
</span><span class="cx">             extProxies=extProxies,
</span><span class="cx">             extReadOnlyProxies=extReadOnlyProxies,
</span><span class="cx">             uid=uid,
</span><ins>+            **kwargs
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # Save attributes of dn and attrs in case you might need them later
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavdirectorytesttest_ldapdirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py (12086 => 12087)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py        2013-12-13 18:21:26 UTC (rev 12086)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_ldapdirectory.py        2013-12-13 21:51:30 UTC (rev 12087)
</span><span class="lines">@@ -541,8 +541,6 @@
</span><span class="cx">                             &quot;recordName&quot;: &quot;cn&quot;,
</span><span class="cx">                             &quot;fullName&quot; : &quot;cn&quot;,
</span><span class="cx">                             &quot;emailAddresses&quot; : [&quot;mail&quot;, &quot;emailAliases&quot;],
</span><del>-                            &quot;firstName&quot; : &quot;givenName&quot;,
-                            &quot;lastName&quot; : &quot;sn&quot;,
</del><span class="cx">                         },
</span><span class="cx">                     },
</span><span class="cx">                     &quot;locations&quot;: {
</span><span class="lines">@@ -552,12 +550,11 @@
</span><span class="cx">                         &quot;filter&quot;: &quot;(objectClass=apple-resource)&quot;, # additional filter for this type
</span><span class="cx">                         &quot;calendarEnabledAttr&quot; : &quot;&quot;, # attribute controlling calendaring
</span><span class="cx">                         &quot;calendarEnabledValue&quot; : &quot;yes&quot;, # &quot;True&quot; value of above attribute
</span><ins>+                        &quot;associatedAddressAttr&quot; : &quot;assocAddr&quot;,
</ins><span class="cx">                         &quot;mapping&quot;: { # maps internal record names to LDAP
</span><span class="cx">                             &quot;recordName&quot;: &quot;cn&quot;,
</span><span class="cx">                             &quot;fullName&quot; : &quot;cn&quot;,
</span><span class="cx">                             &quot;emailAddresses&quot; : &quot;&quot;, # old style, single string
</span><del>-                            &quot;firstName&quot; : &quot;givenName&quot;,
-                            &quot;lastName&quot; : &quot;sn&quot;,
</del><span class="cx">                         },
</span><span class="cx">                     },
</span><span class="cx">                     &quot;resources&quot;: {
</span><span class="lines">@@ -571,10 +568,17 @@
</span><span class="cx">                             &quot;recordName&quot;: &quot;cn&quot;,
</span><span class="cx">                             &quot;fullName&quot; : &quot;cn&quot;,
</span><span class="cx">                             &quot;emailAddresses&quot; : [], # new style, array
</span><del>-                            &quot;firstName&quot; : &quot;givenName&quot;,
-                            &quot;lastName&quot; : &quot;sn&quot;,
</del><span class="cx">                         },
</span><span class="cx">                     },
</span><ins>+                    &quot;addresses&quot;: {
+                        &quot;rdn&quot;: &quot;cn=Buildings&quot;,
+                        &quot;geoAttr&quot; : &quot;coordinates&quot;,
+                        &quot;streetAddressAttr&quot; : &quot;postal&quot;,
+                        &quot;mapping&quot;: { # maps internal record names to LDAP
+                            &quot;recordName&quot;: &quot;cn&quot;,
+                            &quot;fullName&quot; : &quot;cn&quot;,
+                        },
+                    },
</ins><span class="cx">                 },
</span><span class="cx">                 &quot;groupSchema&quot;: {
</span><span class="cx">                     &quot;membersAttr&quot;: &quot;uniqueMember&quot;, # how members are specified
</span><span class="lines">@@ -1514,6 +1518,39 @@
</span><span class="cx">                 self.service.recordType_users)
</span><span class="cx">             self.assertEquals(record.guid, guid.upper())
</span><span class="cx"> 
</span><ins>+            # Location with associated Address
+
+            dn = &quot;cn=odtestlocation,cn=locations,dc=example,dc=com&quot;
+            guid = &quot;D3094652-344B-4633-8DB8-09639FA00FB6&quot;
+            attrs = {
+                &quot;apple-generateduid&quot;: [guid],
+                &quot;cn&quot;: [&quot;odtestlocation&quot;],
+                &quot;assocAddr&quot; : [&quot;6C6CD280-E6E3-11DF-9492-0800200C9A66&quot;],
+            }
+            record = self.service._ldapResultToRecord(dn, attrs,
+                self.service.recordType_locations)
+            self.assertEquals(record.extras, {
+                &quot;associatedAddress&quot;: &quot;6C6CD280-E6E3-11DF-9492-0800200C9A66&quot;
+            })
+           
+            # Address with street and geo
+
+            dn = &quot;cn=odtestaddress,cn=buildings,dc=example,dc=com&quot;
+            guid = &quot;6C6CD280-E6E3-11DF-9492-0800200C9A66&quot;
+            attrs = {
+                &quot;apple-generateduid&quot;: [guid],
+                &quot;cn&quot;: [&quot;odtestaddress&quot;],
+                &quot;coordinates&quot; : [&quot;geo:1,2&quot;],
+                &quot;postal&quot; : [&quot;1 Infinite Loop, Cupertino, CA&quot;],
+            }
+            record = self.service._ldapResultToRecord(dn, attrs,
+                self.service.recordType_addresses)
+            self.assertEquals(record.extras, {
+                &quot;geo&quot;: &quot;geo:1,2&quot;,
+                &quot;streetAddress&quot; : &quot;1 Infinite Loop, Cupertino, CA&quot;,
+            })
+           
+
</ins><span class="cx">         def test_listRecords(self):
</span><span class="cx">             &quot;&quot;&quot;
</span><span class="cx">             listRecords makes an LDAP query (with fake results in this test)
</span></span></pre>
</div>
</div>

</body>
</html>