<!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>[12337] twext/trunk/twext/who/ldap</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/12337">12337</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-01-14 12:30:17 -0800 (Tue, 14 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Some basic queries work now.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#twexttrunktwextwholdap_constantspy">twext/trunk/twext/who/ldap/_constants.py</a></li>
<li><a href="#twexttrunktwextwholdap_servicepy">twext/trunk/twext/who/ldap/_service.py</a></li>
<li><a href="#twexttrunktwextwholdaptesttest_servicepy">twext/trunk/twext/who/ldap/test/test_service.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="twexttrunktwextwholdap_constantspy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/ldap/_constants.py (12336 => 12337)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/ldap/_constants.py        2014-01-14 20:29:48 UTC (rev 12336)
+++ twext/trunk/twext/who/ldap/_constants.py        2014-01-14 20:30:17 UTC (rev 12337)
</span><span class="lines">@@ -22,10 +22,8 @@
</span><span class="cx"> Names, NamedConstant, Values, ValueConstant
</span><span class="cx"> )
</span><span class="cx">
</span><del>-from ..idirectory import (
- FieldName as BaseFieldName, RecordType as BaseRecordType
-)
</del><span class="cx"> from ..expression import MatchType
</span><ins>+from ..util import ConstantsContainer
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -119,25 +117,25 @@
</span><span class="cx"> See U{RFC 4519, section 2<http://tools.ietf.org/html/rfc4519#section-2>}.
</span><span class="cx"> """
</span><span class="cx"> businessCategory = ValueConstant(u"businessCategory")
</span><del>- countryName = ValueConstant(u"c")
- commonName = ValueConstant(u"cn")
- domainComponent = ValueConstant(u"dc")
</del><ins>+ c = ValueConstant(u"c") # country name
+ cn = ValueConstant(u"cn") # common name
+ domainComponent = ValueConstant(u"dc") # domain component
</ins><span class="cx"> description = ValueConstant(u"description")
</span><span class="cx"> destinationIndicator = ValueConstant(u"destinationIndicator")
</span><span class="cx"> distinguishedName = ValueConstant(u"distinguishedName")
</span><span class="cx"> dnQualifier = ValueConstant(u"dnQualifier")
</span><del>- enhancedSearchGuide = ValueConstant(u"enhanced search guide")
</del><ins>+ enhancedSearchGuide = ValueConstant(u"enhancedSearchGuide")
</ins><span class="cx"> facsimileTelephoneNumber = ValueConstant(u"facsimileTelephoneNumber")
</span><span class="cx"> generationQualifier = ValueConstant(u"generationQualifier")
</span><span class="cx"> givenName = ValueConstant(u"givenName")
</span><span class="cx"> houseIdentifier = ValueConstant(u"houseIdentifier")
</span><span class="cx"> initials = ValueConstant(u"initials")
</span><span class="cx"> internationalISDNNumber = ValueConstant(u"internationalISDNNumber")
</span><del>- localityName = ValueConstant(u"l")
</del><ins>+ l = ValueConstant(u"l") # location name
</ins><span class="cx"> member = ValueConstant(u"member")
</span><span class="cx"> name = ValueConstant(u"name")
</span><del>- organizationName = ValueConstant(u"o")
- organizationalUnitName = ValueConstant(u"ou")
</del><ins>+ o = ValueConstant(u"o") # organization name
+ ou = ValueConstant(u"ou") # organizational unit name
</ins><span class="cx"> owner = ValueConstant(u"owner")
</span><span class="cx"> physicalDeliveryOfficeName = ValueConstant(u"physicalDeliveryOfficeName")
</span><span class="cx"> postalAddress = ValueConstant(u"postalAddress")
</span><span class="lines">@@ -149,25 +147,21 @@
</span><span class="cx"> searchGuide = ValueConstant(u"searchGuide")
</span><span class="cx"> seeAlso = ValueConstant(u"seeAlso")
</span><span class="cx"> serialNumber = ValueConstant(u"serialNumber")
</span><del>- surname = ValueConstant(u"sn")
- stateOrProvinceName = ValueConstant(u"st")
</del><ins>+ sn = ValueConstant(u"sn") # surname
+ st = ValueConstant(u"st") # state or province name
</ins><span class="cx"> street = ValueConstant(u"street")
</span><span class="cx"> telephoneNumber = ValueConstant(u"telephoneNumber")
</span><span class="cx"> teletexTerminalIdentifier = ValueConstant(u"teletexTerminalIdentifier")
</span><span class="cx"> telexNumber = ValueConstant(u"telexNumber")
</span><span class="cx"> title = ValueConstant(u"title")
</span><del>- userID = ValueConstant(u"uid")
</del><ins>+ uid = ValueConstant(u"uid") # user id
</ins><span class="cx"> uniqueMember = ValueConstant(u"uniqueMember")
</span><span class="cx"> userPassword = ValueConstant(u"userPassword")
</span><span class="cx"> x121Address = ValueConstant(u"x121Address")
</span><span class="cx"> x500UniqueIdentifier = ValueConstant(u"x500UniqueIdentifier")
</span><span class="cx">
</span><span class="cx">
</span><del>-for c in RFC4519Attribute.iterconstants():
- if c.name != c.value:
- setattr(RFC4519Attribute, c.value, c)
</del><span class="cx">
</span><del>-
</del><span class="cx"> class RFC4519ObjectClass(Values):
</span><span class="cx"> """
</span><span class="cx"> See U{RFC 4519, section 3<http://tools.ietf.org/html/rfc4519#section-2>}.
</span><span class="lines">@@ -188,28 +182,30 @@
</span><span class="cx"> uidObject = ValueConstant(u"uidObject")
</span><span class="cx">
</span><span class="cx">
</span><del>-# http://tools.ietf.org/html/rfc4524
-# http://tools.ietf.org/html/rfc3112 auth schemes
-# http://tools.ietf.org/html/rfc2307
-# http://tools.ietf.org/html/rfc2798
-# http://tools.ietf.org/html/rfc2739 calendar
</del><span class="cx">
</span><ins>+class WhoAttribute(Values):
+ """
+ Attributes needed internally that have no standard name.
+ """
+ who_uid = ValueConstant(u"__who_uid")
+ generatedUUID = ValueConstant(u"__who_guid")
+ objectClass = ValueConstant(u"__who_objectClass")
+ mail = ValueConstant(u"__who_mail")
</ins><span class="cx">
</span><span class="cx">
</span><del>-# Maps field name -> LDAP attribute name
-DEFAULT_FIELDNAME_MAP = {
- BaseFieldName.uid: u"uid", # FIXME
- BaseFieldName.guid: u"entryUUID", # FIXME
- BaseFieldName.recordType: u"objectClass",
- BaseFieldName.shortNames: RFC4519Attribute.userID.value,
- BaseFieldName.fullNames: RFC4519Attribute.commonName.value,
- BaseFieldName.emailAddresses: u"mail", # FIXME
- BaseFieldName.password: u"userPassword", # FIXME
-}
</del><span class="cx">
</span><ins>+LDAPAttribute = ConstantsContainer((
+ RFC4519Attribute,
+ WhoAttribute,
+))
</ins><span class="cx">
</span><del>-# Maps record type -> LDAP organizational unit name
-DEFAULT_RECORDTYPE_MAP = {
- BaseRecordType.user: u"People", # FIXME
- BaseRecordType.group: u"Group", # FIXME
-}
</del><ins>+LDAPObjectClass = ConstantsContainer((
+ RFC4519ObjectClass,
+))
+
+
+# http://tools.ietf.org/html/rfc4524
+# http://tools.ietf.org/html/rfc3112 auth schemes
+# http://tools.ietf.org/html/rfc2307
+# http://tools.ietf.org/html/rfc2798
+# http://tools.ietf.org/html/rfc2739 calendar
</ins></span></pre></div>
<a id="twexttrunktwextwholdap_servicepy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/ldap/_service.py (12336 => 12337)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/ldap/_service.py        2014-01-14 20:29:48 UTC (rev 12336)
+++ twext/trunk/twext/who/ldap/_service.py        2014-01-14 20:30:17 UTC (rev 12337)
</span><span class="lines">@@ -21,6 +21,8 @@
</span><span class="cx"> LDAP directory service implementation.
</span><span class="cx"> """
</span><span class="cx">
</span><ins>+from uuid import UUID
+
</ins><span class="cx"> import ldap
</span><span class="cx">
</span><span class="cx"> # from zope.interface import implementer
</span><span class="lines">@@ -36,7 +38,7 @@
</span><span class="cx"> DirectoryServiceError, DirectoryAvailabilityError,
</span><span class="cx"> # InvalidDirectoryRecordError,
</span><span class="cx"> # QueryNotSupportedError,
</span><del>- # FieldName as BaseFieldName,
</del><ins>+ FieldName as BaseFieldName,
</ins><span class="cx"> RecordType as BaseRecordType,
</span><span class="cx"> # IPlaintextPasswordVerifier, IHTTPDigestVerifier,
</span><span class="cx"> )
</span><span class="lines">@@ -52,7 +54,7 @@
</span><span class="cx"> # iterFlags,
</span><span class="cx"> ConstantsContainer,
</span><span class="cx"> )
</span><del>-from ._constants import DEFAULT_FIELDNAME_MAP, DEFAULT_RECORDTYPE_MAP
</del><ins>+from ._constants import LDAPAttribute, LDAPObjectClass
</ins><span class="cx"> from ._util import (
</span><span class="cx"> ldapQueryStringFromMatchExpression,
</span><span class="cx"> ldapQueryStringFromCompoundExpression,
</span><span class="lines">@@ -61,6 +63,27 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><ins>+# Maps field name -> LDAP attribute name
+# FIXME: Use constants
+DEFAULT_FIELDNAME_MAP = {
+ BaseFieldName.uid: LDAPAttribute.who_uid.value,
+ BaseFieldName.guid: LDAPAttribute.generatedUUID.value,
+ BaseFieldName.recordType: LDAPAttribute.objectClass.value,
+ BaseFieldName.shortNames: LDAPAttribute.uid.value,
+ BaseFieldName.fullNames: LDAPAttribute.cn.value,
+ BaseFieldName.emailAddresses: LDAPAttribute.mail.value,
+ BaseFieldName.password: LDAPAttribute.userPassword.value,
+}
+
+
+# Maps record type -> LDAP object class name
+DEFAULT_RECORDTYPE_MAP = {
+ BaseRecordType.user: LDAPObjectClass.person.value,
+ BaseRecordType.group: LDAPObjectClass.groupOfUniqueNames.value,
+}
+
+
+
</ins><span class="cx"> #
</span><span class="cx"> # Exceptions
</span><span class="cx"> #
</span><span class="lines">@@ -76,6 +99,13 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><ins>+class LDAPConfigurationError(ValueError):
+ """
+ LDAP configuration error.
+ """
+
+
+
</ins><span class="cx"> class LDAPConnectionError(DirectoryAvailabilityError):
</span><span class="cx"> """
</span><span class="cx"> LDAP connection error.
</span><span class="lines">@@ -134,8 +164,9 @@
</span><span class="cx"> tlsCACertificateDirectory=None,
</span><span class="cx"> useTLS=False,
</span><span class="cx"> debug=False,
</span><del>- fieldNameMap=DEFAULT_FIELDNAME_MAP,
- recordTypeMap=DEFAULT_RECORDTYPE_MAP,
</del><ins>+ fieldNameToAttributeMap=DEFAULT_FIELDNAME_MAP,
+ recordTypeToObjectClassMap=DEFAULT_RECORDTYPE_MAP,
+ uidField=BaseFieldName.uid,
</ins><span class="cx"> ):
</span><span class="cx"> self.url = url
</span><span class="cx"> self._baseDN = baseDN
</span><span class="lines">@@ -159,10 +190,29 @@
</span><span class="cx"> else:
</span><span class="cx"> self._debug = None
</span><span class="cx">
</span><del>- self._fieldNameMap = fieldNameMap
- self._recordTypeMap = recordTypeMap
</del><ins>+ def reverseDict(source):
+ new = {}
</ins><span class="cx">
</span><ins>+ for k, v in source.iteritems():
+ if v in new:
+ raise LDAPConfigurationError(
+ u"Field name map has duplicate values: {0}".format(v)
+ )
+ new[v] = k
</ins><span class="cx">
</span><ins>+ return new
+
+ self._fieldNameToAttributeMap = fieldNameToAttributeMap
+ self._attributeToFieldNameMap = reverseDict(fieldNameToAttributeMap)
+
+ self._recordTypeToObjectClassMap = recordTypeToObjectClassMap
+ self._objectClassToRecordTypeMap = reverseDict(
+ recordTypeToObjectClassMap
+ )
+
+ self._uidField = uidField
+
+
</ins><span class="cx"> @property
</span><span class="cx"> def realmName(self):
</span><span class="cx"> return u"{self.url}".format(self=self)
</span><span class="lines">@@ -236,28 +286,90 @@
</span><span class="cx"> def _recordsFromQueryString(self, queryString):
</span><span class="cx"> connection = yield self._connect()
</span><span class="cx">
</span><del>- # print("+" * 80)
- # print("Query:", repr(queryString))
</del><ins>+ self.log.debug("Performing LDAP query: {query}", query=queryString)
</ins><span class="cx">
</span><span class="cx"> reply = connection.search_s(
</span><span class="cx"> self._baseDN, ldap.SCOPE_SUBTREE, queryString # attrs
</span><span class="cx"> )
</span><span class="cx">
</span><del>- # print("Reply:", repr(reply))
- # print("+" * 80)
-
</del><span class="cx"> records = []
</span><span class="cx">
</span><del>- for recordData in reply:
- raise NotImplementedError(reply)
</del><ins>+ # Note: self._uidField is the name of the field in
+ # self._fieldNameToAttributeMap that tells us which LDAP attribute
+ # we are using to determine the UID of the record.
</ins><span class="cx">
</span><ins>+ uidField = self.fieldName.uid
+ uidAttribute = self._fieldNameToAttributeMap[self._uidField]
+
+ recordTypeField = self.fieldName.recordType
+ recordTypeAttribute = (
+ self._fieldNameToAttributeMap[self.fieldName.recordType]
+ )
+
+ for dn, recordData in reply:
+
+ if recordTypeAttribute not in recordData:
+ self.log.debug(
+ "Ignoring LDAP record data with no record type attribute "
+ "{source.fieldName.recordType!r}: {recordData!r}",
+ self=self, recordData=recordData
+ )
+ continue
+
+ # Make a dict of fields -> values from the incoming dict of
+ # attributes -> values.
+
+ fields = dict([
+ (self._attributeToFieldNameMap[k], v)
+ for k, v in recordData.iteritems()
+ ])
+
+ # Make sure the UID is populated
+
+ try:
+ fields[uidField] = recordData[uidAttribute]
+ except KeyError:
+ self.log.debug(
+ "Ignoring LDAP record data with no UID attribute "
+ "{source._uidField!r}: {recordData!r}",
+ self=self, recordData=recordData
+ )
+ continue
+
+
+ # Coerce data to the correct type
+
+ for fieldName, value in fields.iteritems():
+ valueType = self.fieldName.valueType(fieldName)
+
+ if fieldName is recordTypeField:
+ value = self._objectClassToRecordTypeMap[value]
+ elif valueType in (unicode, UUID):
+ value = valueType(value)
+ else:
+ raise LDAPConfigurationError(
+ "Unknown value type {0} for field {1}".format(
+ valueType, fieldName
+ )
+ )
+
+ fields[fieldName] = value
+
+ # Make a record object from fields.
+
+ record = DirectoryRecord(self, fields)
+ records.append(record)
+
+ self.log.debug("LDAP results: {records}", records=records)
+
</ins><span class="cx"> returnValue(records)
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> def recordsFromNonCompoundExpression(self, expression, records=None):
</span><span class="cx"> if isinstance(expression, MatchExpression):
</span><span class="cx"> queryString = ldapQueryStringFromMatchExpression(
</span><del>- expression, self._fieldNameMap, self._recordTypeMap
</del><ins>+ expression,
+ self._fieldNameToAttributeMap, self._recordTypeToObjectClassMap
</ins><span class="cx"> )
</span><span class="cx"> return self._recordsFromQueryString(queryString)
</span><span class="cx">
</span><span class="lines">@@ -271,7 +383,8 @@
</span><span class="cx"> return ()
</span><span class="cx">
</span><span class="cx"> queryString = ldapQueryStringFromCompoundExpression(
</span><del>- expression, self._fieldNameMap, self._recordTypeMap
</del><ins>+ expression,
+ self._fieldNameToAttributeMap, self._recordTypeToObjectClassMap
</ins><span class="cx"> )
</span><span class="cx"> return self._recordsFromQueryString(queryString)
</span><span class="cx">
</span></span></pre></div>
<a id="twexttrunktwextwholdaptesttest_servicepy"></a>
<div class="modfile"><h4>Modified: twext/trunk/twext/who/ldap/test/test_service.py (12336 => 12337)</h4>
<pre class="diff"><span>
<span class="info">--- twext/trunk/twext/who/ldap/test/test_service.py        2014-01-14 20:29:48 UTC (rev 12336)
+++ twext/trunk/twext/who/ldap/test/test_service.py        2014-01-14 20:30:17 UTC (rev 12337)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> url = "ldap://localhost/"
</span><del>- baseDN = u"o=org"
</del><ins>+ baseDN = u"ou=calendarserver,o=org"
</ins><span class="cx"> realmName = unicode(url)
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -84,22 +84,6 @@
</span><span class="cx"> class DirectoryServiceConvenienceTestMixIn(
</span><span class="cx"> BaseDirectoryServiceConvenienceTestMixIn
</span><span class="cx"> ):
</span><del>- def test_recordWithUID(self):
- return (
- BaseDirectoryServiceConvenienceTestMixIn.test_recordWithUID(self)
- )
-
- test_recordWithUID.todo = "needs a seed?"
-
-
- def test_recordWithGUID(self):
- return (
- BaseDirectoryServiceConvenienceTestMixIn.test_recordWithGUID(self)
- )
-
- test_recordWithGUID.todo = "needs a seed?"
-
-
</del><span class="cx"> def test_recordsWithRecordType(self):
</span><span class="cx"> return (
</span><span class="cx"> BaseDirectoryServiceConvenienceTestMixIn
</span><span class="lines">@@ -109,25 +93,7 @@
</span><span class="cx"> test_recordsWithRecordType.todo = "needs a seed?"
</span><span class="cx">
</span><span class="cx">
</span><del>- def test_recordWithShortName(self):
- return (
- BaseDirectoryServiceConvenienceTestMixIn
- .test_recordWithShortName(self)
- )
</del><span class="cx">
</span><del>- test_recordWithShortName.todo = "needs a seed?"
-
-
- def test_recordsWithEmailAddress(self):
- return (
- BaseDirectoryServiceConvenienceTestMixIn
- .test_recordsWithEmailAddress(self)
- )
-
- test_recordsWithEmailAddress.todo = "needs a seed?"
-
-
-
</del><span class="cx"> class DirectoryServiceConnectionTestMixIn(object):
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_connect_defaults(self):
</span><span class="lines">@@ -155,7 +121,7 @@
</span><span class="cx"> Connect with UsernamePassword credentials.
</span><span class="cx"> """
</span><span class="cx"> credentials = UsernamePassword(
</span><del>- u"uid=wsanchez,cn=user,dc=calendarserver,dc=org",
</del><ins>+ u"uid=wsanchez,cn=user,ou=calendarserver,o=org",
</ins><span class="cx"> u"__password__"
</span><span class="cx"> )
</span><span class="cx"> service = self.service(credentials=credentials)
</span><span class="lines">@@ -168,7 +134,7 @@
</span><span class="cx"> Connect with UsernamePassword credentials.
</span><span class="cx"> """
</span><span class="cx"> credentials = UsernamePassword(
</span><del>- u"uid=wsanchez,cn=user,dc=calendarserver,dc=org",
</del><ins>+ u"uid=wsanchez,cn=user,ou=calendarserver,o=org",
</ins><span class="cx"> u"zehcnasw"
</span><span class="cx"> )
</span><span class="cx"> service = self.service(credentials=credentials)
</span><span class="lines">@@ -249,7 +215,7 @@
</span><span class="cx">
</span><span class="cx"> data = {
</span><span class="cx"> u"o={o}".format(o=o): dict(o=o),
</span><del>- u"ou={ou}".format(ou=ou): dict(ou=ou),
</del><ins>+ u"ou={ou},o={o}".format(ou=ou, o=o): dict(ou=ou),
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> def toUnicode(obj):
</span><span class="lines">@@ -273,7 +239,7 @@
</span><span class="cx">
</span><span class="cx"> for records in service.index[service.fieldName.uid].itervalues():
</span><span class="cx"> for record in records:
</span><del>- dn = u"uid={uid},cn={cn},dc={ou},dc={o}".format(
</del><ins>+ dn = u"uid={uid},cn={cn},ou={ou},o={o}".format(
</ins><span class="cx"> uid=record.shortNames[0], cn=record.recordType.name, ou=ou, o=o
</span><span class="cx"> )
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>