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 Python-LDAP-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/python-ldap-dev