1 from ldaptor.protocols.ldap import ldaperrors, ldapsyntax
2 from ldaptor.protocols import pureldap
3 from ldaptor import schema
4
6 o=ldapsyntax.LDAPEntry(client=client,
7 dn=subschemaSubentry)
8 d=o.search(scope=pureldap.LDAP_SCOPE_baseObject,
9 sizeLimit=1,
10 attributes=["attributeTypes", "objectClasses"])
11 def handleSearchResults(l):
12 if len(l)==0:
13 raise ldaperrors.LDAPOther, "No such DN"
14 elif len(l)==1:
15 o=l[0]
16
17 attributeTypes = []
18 objectClasses = []
19 for text in o.get("attributeTypes", []):
20 attributeTypes.append(schema.AttributeTypeDescription(str(text)))
21 for text in o.get("objectClasses", []):
22 objectClasses.append(schema.ObjectClassDescription(str(text)))
23 assert attributeTypes, "LDAP server doesn't give attributeTypes for subschemaSubentry dn=%s"%o.dn
24 return (attributeTypes, objectClasses)
25 else:
26 raise ldaperrors.LDAPOther, "DN matched multiple entries"
27 d.addCallback(handleSearchResults)
28 return d
29
30 -def fetch(client, baseObject):
49
50 d.addCallback(handleSearchResults)
51 d.addCallback(_fetchCb, client)
52 return d
53