Searching

>>> from twisted.trial.util import deferredResult
>>> proto=deferredResult(d)
>>> proto
<ldaptor.protocols.ldap.ldapclient.LDAPClient 
instance at 0x40619dac>
>>> from ldaptor.protocols.ldap import ldapsyntax
>>> baseEntry=ldapsyntax.LDAPEntry(client=proto, dn=dn)
>>> d2=baseEntry.search(filterText='(gn=j*)')
>>> results=deferredResult(d2)
>>> results
[LDAPEntry(dn='givenName=John+sn=Smith,ou=People,
dc=example,dc=com', attributes={'description': ['Some text.'], 
'facsimileTelephoneNumber': ['555-1235'], 'givenName': ['John'], 
'objectClass': ['addressbookPerson'], 'sn': ['Smith'], 
'telephoneNumber': ['555-1234']}), LDAPEntry(dn=
'givenName=John+sn=Doe,ou=People,dc=example,dc=com', 
attributes={'c': ['US'], 'givenName': ['John'], 'l': ['New York City'], 
'objectClass': ['addressbookPerson'], 'postOfficeBox': ['123'], 
'postalAddress': ['Backstreet'], 'postalCode': ['54321'], 
'sn': ['Doe'], 'st': ['NY'], 'street': ['Back alley']})]
>>> results[0]
LDAPEntry(dn=
'givenName=John+sn=Smith,ou=People,dc=example,dc=com', 
attributes={'description': ['Some text.'], 
'facsimileTelephoneNumber': ['555-1235'], 'givenName': ['John'], 
'objectClass': ['addressbookPerson'], 'sn': ['Smith'], 
'telephoneNumber': ['555-1234']})
>>> results[1]
LDAPEntry(dn=
'givenName=John+sn=Doe,ou=People,dc=example,dc=com', 
attributes={'c': ['US'], 'givenName': ['John'], 'l': ['New York City'], 
'objectClass': ['addressbookPerson'], 'postOfficeBox': ['123'], 
'postalAddress': ['Backstreet'], 'postalCode': ['54321'], 
'sn': ['Doe'], 'st': ['NY'], 'street': ['Back alley']})
>>> results[3]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IndexError: list index out of range
>>> print results[0]
dn: givenName=John+sn=Smith,ou=People,dc=example,dc=com
objectClass: addressbookPerson
description: Some text.
facsimileTelephoneNumber: 555-1235
givenName: John
sn: Smith
telephoneNumber: 555-1234