Hi Guruprasad
Had the same issue and someone was kind enough to point me in the right
direction. Here's what I was told
"A uid has to be changed into a legible format Chapter 3 of RFC 4515 (LDAPv3
filter strings) starts with:
The string representation of an LDAP search filter is a string of UTF-8
[RFC3629] encoded Unicode characters [Unicode] [..]
So please have a look at RFC 4515 to find out how to escape hex values in a
search filter.
Function ldap.filter.escape_filter_chars() is helpful for that."
Thanks
fintan
On Sunday 20 September 2009 15:02:14 Guruprasad wrote:
> Hi,
> I have been trying to write a function to search a LDAP directory by
> using the python-ldap APIs.
> Here is the code I have written:
>
> <snip>
> def getNextUid():
> uidList=[]
> try:
> l=ldap.initialize(ldap_host)
> l.bind_s(ldap_admin_dn,ldap_admin_pass)
>
> ldap_result=l.search(ldap_base_dn,ldap.SCOPE_SUBTREE,'cn=*',['uidNumber'])
> while 1:
> result_type, result_data=l.result(ldap_result,0)
> if (result_data == []):
> break
> a=result_data[0][1]['uidNumber']
> print a
> except ldap.SERVER_DOWN:
> print "LDAP server down"
> </snip>
>
> What I am trying to do in this piece of code is get the list of the
> values of 'uidNumber' attribute. The search operation returns a list
> containing a tuple. The tuple contains the DN as one value and a
> dictionary with uidNumber and its value. I am trying to extract the
> value of the uidNumber. I found that result_data was a dictionary
> having a key 'uidNumber', but when I try to print its value, I get a
> KeyError. Strangely, when I print result_data.keys(), 'uidNumber' is
> present.
>
>
> Thank you.
>
> Regards,
> Guruprasad.
>
> ---------------------------------------------------------------------------
> --- Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register
> now! http://p.sf.net/sfu/devconf
> _______________________________________________
> Python-LDAP-dev mailing list
> Pyt...@li...
> https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
>
|