[Twisted-Python] Ldaptor attributes in Python 3
Peter Westlake
peter.westlake at pobox.com
Sat Jan 23 17:48:44 MST 2021
On Sat, 23 Jan 2021, at 22:09, Adi Roiban wrote:
> Hi,
>
> On Fri, 22 Jan 2021 at 11:15, Peter Westlake <peter.westlake at pobox.com> wrote:
>> I'm using Ldaptor for LDAP access because it fits in with Twisted, and the results are a bit mystifying.
>> ...
>
> Can you send a full example of how you would like the API to behave ? Or send a PR ? :)
>
> I am doing a client-side search like this and I was happy with API
>
> o = LDAPEntry(client, base_dn)
> results = yield o.search(
> attributes=[b'objectclass'],
> scope=LDAP_SCOPE_wholeSubtree,
> filterText='(cn=test)',
> )
> for result in results:
> print (result['objectclass'])
Thanks, Adi!
My code looks like this:
> o = LDAPEntry(client, base_dn)
> results = yield o.search(filterText='(uid=peterw)')
> for result in results:
> print (result['cn'])
I would like this to print:
Peter Westlake
or
b'Peter Westlake'
What it actually prints is:
JournaledLDAPAttributeSet(b'cn', [b'Peter Westlake])
Having searched the WWW for examples, it looks as though other people have seen it behaving in exactly the way I want, but it's not doing that for me, with Python 3.6.8 on CentOS 7.
Peter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20210124/e9117b70/attachment.htm>
More information about the Twisted-Python
mailing list