From radhikarora15 at gmail.com Thu Jul 5 08:48:54 2018 From: radhikarora15 at gmail.com (Radhika Arora) Date: Thu, 5 Jul 2018 18:18:54 +0530 Subject: [python-ldap] Need success response code in LDAP search request Message-ID: Hi Team, Recently I got a chance to implement LDAP search functionality in python and this library helped me alot. I had to implement LDAP search functionality and while doing this implementation I found that *search_ext_st/search_s/search_ext()* all these methods do not return any success response code. though I got the correct results on the basis of filter_query passed to the function. Search functions return some msgid which is unique in every ldap search request and passing this msgid to *result()* gives the result_type and result_data whereas program got hung when msgid was passed to *result3/result4()* method. While exploring the code I found *ldap.OPT_SUCCESS* variable whose value is 0(I think this is success response code which should be present in response of LDAP search). I am wondering whether success response_code is not present in the ldap search response or I am misunderstanding/missing something in received response. Please let me know how can I unblock myself. Thanks & Regards, Radhika Arora -------------- next part -------------- An HTML attachment was scrubbed... URL: From radhikarora15 at gmail.com Thu Jul 5 08:54:12 2018 From: radhikarora15 at gmail.com (Radhika Arora) Date: Thu, 5 Jul 2018 18:24:12 +0530 Subject: [python-ldap] Need success response code in LDAP search request In-Reply-To: References: Message-ID: Please ignore program hung up problem when msgid was passed to result3/result4, I just noticed that default value of timeout is negative in search_ext() in ldapobject.py which says it will be blocked indefinitely. Thanks, Radhika Arora On Thu, Jul 5, 2018 at 6:18 PM, Radhika Arora wrote: > Hi Team, > > Recently I got a chance to implement LDAP search functionality in python > and this library helped me alot. > > I had to implement LDAP search functionality and while doing this > implementation I found that > *search_ext_st/search_s/search_ext()* all these methods do not return any > success response code. > though I got the correct results on the basis of filter_query passed to > the function. > > Search functions return some msgid which is unique in every ldap search > request and passing this msgid to *result()* gives the result_type and > result_data whereas program got hung when msgid was passed to > *result3/result4()* method. > > While exploring the code I found *ldap.OPT_SUCCESS* variable whose value > is 0(I think this is success response code which should be present in > response of LDAP search). > > I am wondering whether success response_code is not present in the ldap > search response or I am misunderstanding/missing something in received > response. > > Please let me know how can I unblock myself. > > Thanks & Regards, > Radhika Arora > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vikramns at gmail.com Thu Jul 19 08:56:34 2018 From: vikramns at gmail.com (Vikram NS) Date: Thu, 19 Jul 2018 18:26:34 +0530 Subject: [python-ldap] search output as ldif in a file Message-ID: Hi Folks, Thanks in advance on helping me out I am doing a bulk search and hoping to build a LDIF file with the results, following is the code snippet try: entries = lw_conn.extend.standard.paged_search(search_base=base_dn, search_filter=lw_filter, search_scope=SUBTREE, attributes=retrive_attrs, paged_size=page_size, generator=True) except Exception as e: sys.exit("Search failed: %s" % e) ldif_writer = LDIFWriter(open(args.write,'wb'), base64_attrs=None, cols=160) for entry in entries: entry['raw_attributes'].pop('nTSecurityDescriptor') ldif_writer.unparse(entry['dn'], entry['raw_attributes']) Getting the following error: Traceback (most recent call last): File "./ldap_export.py", line 111, in ldif_writer.unparse(entry['dn'], entry['attributes']) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ldif3.py", line 199, in unparse raise ValueError("Argument record must be dictionary or list") ValueError: Argument record must be dictionary or list Tried converting entry['attributes'] into a dictionary, with that LDIFWrite worked but all the attributes got encoded in base64, base64_attrs=None didn't help cn:: VmlrcmFtIE4gUw== Thanks, Vikram -------------- next part -------------- An HTML attachment was scrubbed... URL: From bilalpandit at gmail.com Fri Jul 27 16:59:04 2018 From: bilalpandit at gmail.com (Bilal Pandit) Date: Fri, 27 Jul 2018 13:59:04 -0700 Subject: [python-ldap] Unable to do basic search in LDAP Message-ID: <706B8350-F6A3-4AF7-B7B7-7CA44E9159D5@gmail.com> Hey all, I have a decent understanding of python and have been attempting to do some basic LDAP searches on some open servers. However, I continually get the error {?desc?: u?No such object?}. I looked up some online sites, but none of them offered a working solution. I was hoping one of you guys could give me a hand. import ldap keyword = "boyle" def main(): server = "ldap.forumsys.com" who = "cn=read-only-admin,dc=example,dc=com" cred = "password" try: l = ldap.open(server) l.simple_bind_s(who,cred) print "Bound to server Boyx" l.protocol_version = ldap.VERSION3 print "Seaching" mysearch (l,keyword) except ldap.LDAPError: print "Couldnt connect" def mysearch(l, keyword): base = "" scope = ldap.SCOPE_SUBTREE filter = "cn=" + "*" + keyword + "*" retrieve_attributes = None count = 0 result_set = [] timeout = 0 try: result_id = l.search(base,scope,filter, retrieve_attributes) while l != 1: result_type, result_data = l.result(result_id, timeout) if (result_data == []): break else: if result_type == ldap.RES_SEARCH_ENTRY: result_set.append(result_data) if len (result_set = 0): print "No Results" for i in range (len(result_set)): for entry in result_set[i]: try: name = entry[1]['cn'][0] mail = entry[1]['mail'][0] #phone = entry[1]['telephonenumber'][0] #desc = entry[1]['description'][0] count = count + 1 print name + mail print"Its working" except: pass except ldap.LDAPError, error_message: print error_message main() I am using Python 2.7 as well. Thank you so much for your time, and I would appreciate it if you could provide some aid. -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at stroeder.com Sat Jul 28 11:42:02 2018 From: michael at stroeder.com (=?UTF-8?Q?Michael_Str=c3=b6der?=) Date: Sat, 28 Jul 2018 17:42:02 +0200 Subject: [python-ldap] Unable to do basic search in LDAP In-Reply-To: <706B8350-F6A3-4AF7-B7B7-7CA44E9159D5@gmail.com> References: <706B8350-F6A3-4AF7-B7B7-7CA44E9159D5@gmail.com> Message-ID: <678a5082-7990-924d-9a2a-bcc5ec45a9da@stroeder.com> On 07/27/2018 10:59 PM, Bilal Pandit wrote: > I have a decent understanding of python and have been attempting to do > some basic LDAP searches on some open servers. However, I continually > get the error {?desc?: u?No such object?}. See my answer to your question here: https://stackoverflow.com/questions/51566846/python-ldap-unable-to-do-any-basic-search-queries-on-open-server/51572125#51572125 Ciao, Michael. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3829 bytes Desc: S/MIME Cryptographic Signature URL: