From: Joel H. <Joe...@Op...> - 2009-03-03 04:22:26
|
I'm trying to use SimplePagedResultsControl so I can pull some data out of Active Directory that has a Server-Limit set. I got most of my code from this guide http://www.novell.com/coolsolutions/tip/18274.html When I try and run it I get this dump: """ SimplePagedResultsControl(1.2.840.113556.1.4.319,True,(10, '')) Traceback (most recent call last): File "./test_ldap_brakeit.py", line 29, in ? msgid = l.search_ext(base, ldap.SCOPE_SUBTREE, 'objectclass=user', serverctrls=[lc]) File "/usr/lib64/python2.4/site-packages/ldap/ldapobject.py", line 468, in search_ext EncodeControlTuples(serverctrls), File "/usr/lib64/python2.4/site-packages/ldap/controls.py", line 93, in EncodeControlTuples result = [ File "/usr/lib64/python2.4/site-packages/ldap/controls.py", line 45, in getEncodedTuple return (self.controlType,self.criticality,self.encodeControlValue(self.controlValue)) File "/usr/lib64/python2.4/site-packages/ldap/controls.py", line 78, in encodeControlValue return _ldap.encode_page_control(size,cookie) ldap.ENCODING_ERROR """ Server is RHEL5.2 , not too sure about the Active Directory I think it is running on Windows Server 2003. Here is the code: #!/usr/bin/python # import ldap,ldap.async,pprint from ldap.controls import SimplePagedResultsControl server = 'xxxx.com' ldap_version = 3 base = 'dc=example,dc=com' binddn = '' bindpw = '' userbase = '' port = 3268 page_size = 10 l = ldap.open(server,port) l.protocol_version = ldap_version l.simple_bind_s(binddn, bindpw) ldap.set_option(ldap.OPT_REFERRALS, 0) lc = SimplePagedResultsControl( ldap.LDAP_CONTROL_PAGE_OID, True, (page_size,'') ) print lc msgid = l.search_ext(base, ldap.SCOPE_SUBTREE, 'objectclass=user', serverctrls=[lc]) pages = 0 while True: pages += 1 print "Getting page %d" % (pages,) rtype,rdata,rmsgid,serverctrls = l.result3(msgid) print "%d results" % len(rdata) pctrls = [ c for c in serverctrls if c.controlType == ldap.LDAP_CONTROL_PAGE_OID ] if pctrls: est, cookie = pctrls[0].controlValue if cookie: lc.controlValue = (page_size,cookie) msgid = l.search_ext(base, ldap.SCOPE_SUBTREE, 'objectclass=user', serverctrls=[lc]) else: break else: print "Warning: Server ignores RFC 2696 control" Joel Heenan ________________________________ Information contained in this communication (including any attachments) is confidential and may be privileged or subject to copyright. If you have received this communication in error you are not authorised to use the information in any way and Optiver requests that you notify the sender by return email, destroy all copies and delete the information from your system. Optiver does not represent, warrant or guarantee that this communication is free from computer viruses or other defects or that the integrity of this communication has been maintained. Any views expressed in this communication are those of the individual sender. Optiver does not accept liability for any loss or damage caused directly or indirectly by this communication or its use. Please consider the environment before printing this email. |
From: Michael S. <mi...@st...> - 2009-03-03 13:01:18
|
Joel Heenan wrote: > > I'm trying to use SimplePagedResultsControl so I can pull some data out > of Active Directory that has a Server-Limit set. I got most of my code > from this guide http://www.novell.com/coolsolutions/tip/18274.html Since I posted this code I think it works. ;-) > File "/usr/lib64/python2.4/site-packages/ldap/controls.py", line 78, > in encodeControlValue > > return _ldap.encode_page_control(size,cookie) > > ldap.ENCODING_ERROR It seems you're running on a 64-bit platform. I did never test python-ldap on such a system. Which version of python-ldap is it? Did you compile it yourself? Which versions of OpenLDAP libs are used? > Server is RHEL5.2 Hmm, isn't this quite old? I'd guess old versions of python-ldap and OpenLDAP are shipped with this release. Ciao, Michael. |
From: Russell J. <ra...@cs...> - 2009-03-04 07:19:37
Attachments:
signature.asc
|
Michael Ströder wrote: > It seems you're running on a 64-bit platform. I did never test > python-ldap on such a system. Which version of python-ldap is it? Did > you compile it yourself? Which versions of OpenLDAP libs are used? > Just as a data point, I've been running python-ldap (from ports) on FreeBSD-amd64 since 6.x without issue. -- Russell A. Jackson <ra...@cs...> Network Analyst California State University, Bakersfield Q: What do they call the alphabet in Arkansas? A: The impossible dream. |
From: Joel H. <Joe...@Op...> - 2009-03-04 00:31:14
|
Hi Michael, Comments inline: > Michael Ströder wrote: > Joel Heenan wrote: > > > File "/usr/lib64/python2.4/site-packages/ldap/controls.py", line > 78, > > in encodeControlValue > > > > return _ldap.encode_page_control(size,cookie) > > > > ldap.ENCODING_ERROR > > It seems you're running on a 64-bit platform. I did never test > python-ldap on such a system. Which version of python-ldap is it? Did > you compile it yourself? Which versions of OpenLDAP libs are used? > I am using 64-bit RPM's compiled by RedHat for RHEL5.2 . The 32-bit variants are installed I'll see if I can work out how to force it to use them. Here are the versions involved, but be aware RedHat versions include backporting so it can be difficult to say exactly what is included: openldap-2.3.27-8.el5_1.3 openldap-devel-2.3.27-8.el5_1.3 python-ldap-2.2.0-2.1 > > Server is RHEL5.2 > > Hmm, isn't this quite old? I'd guess old versions of python-ldap and > OpenLDAP are shipped with this release. Err RHEL5.2 is the latest stable I believe. RHEL5.3 may have been released. Not to be confused with RedHat 5.2 which is of course ancient :-) Joel Information contained in this communication (including any attachments) is confidential and may be privileged or subject to copyright. If you have received this communication in error you are not authorised to use the information in any way and Optiver requests that you notify the sender by return email, destroy all copies and delete the information from your system. Optiver does not represent, warrant or guarantee that this communication is free from computer viruses or other defects or that the integrity of this communication has been maintained. Any views expressed in this communication are those of the individual sender. Optiver does not accept liability for any loss or damage caused directly or indirectly by this communication or its use. Please consider the environment before printing this email. |
From: Michael S. <mi...@st...> - 2009-03-04 01:51:00
|
Joel Heenan wrote: > Hi Michael, > > Comments inline: > >> Michael Ströder wrote: >> Joel Heenan wrote: >> >>> File "/usr/lib64/python2.4/site-packages/ldap/controls.py", line >> 78, >>> in encodeControlValue >>> >>> return _ldap.encode_page_control(size,cookie) >>> >>> ldap.ENCODING_ERROR >> It seems you're running on a 64-bit platform. I did never test >> python-ldap on such a system. Which version of python-ldap is it? Did >> you compile it yourself? Which versions of OpenLDAP libs are used? > > I am using 64-bit RPM's compiled by RedHat for RHEL5.2 . The 32-bit > variants are installed I'll see if I can work out how to force it to > use them. > > Here are the versions involved, but be aware RedHat versions include > backporting so it can be difficult to say exactly what is included: > > openldap-2.3.27-8.el5_1.3 > openldap-devel-2.3.27-8.el5_1.3 > python-ldap-2.2.0-2.1 These releases are old: OpenLDAP 2.3.27 was released 2006-08-19 python-ldap 2.2.0 was released 2006-04-10 There have been numerous bug fixes to both packages since then. While I don't have a 64-bit box myself there were several related fixes contributed and tested by others. So I suggest to build recent releases of both from source and test with that. >>> Server is RHEL5.2 >> Hmm, isn't this quite old? I'd guess old versions of python-ldap and >> OpenLDAP are shipped with this release. > > Err RHEL5.2 is the latest stable I believe. Whatever stable means to Red Hat for these particular packages. Sorry, if you insist on using these ancient versions I have to point you to Red Hat's support. Ciao, Michael. |