From rmeggins at redhat.com Fri Oct 1 19:11:24 2010 From: rmeggins at redhat.com (Rich Megginson) Date: Fri, 01 Oct 2010 11:11:24 -0600 Subject: python-ldap ticket #2829057 In-Reply-To: <4CA4E161.8020406@stroeder.com> References: <4AFFE325.8040107@stroeder.com> <4B030331.3020807@redhat.com> <4CA2FCEC.50105@stroeder.com> <4CA4D14B.70309@redhat.com> <4CA4E161.8020406@stroeder.com> Message-ID: <4CA6163C.7080404@redhat.com> Michael Str?der wrote: > Rich Megginson wrote: > >> I have some patches, and I've built them locally. How do I set up my >> environment to test them, on a machine with python2.4 and python-ldap >> already installed in the system python site-packages directory? >> > > If you built with > > python setup.py build > > you have now everything compiled under build/. > You can then install with > > python setup.py install > > but this overwrites or conflicts with an already installed packaged version of > python-ldap. > > Files get installed into > /usr/lib/python2.4/site-packages/ > or > /usr/local/lib/python2.4/site-packages/ > depending on your Python package. > > Ciao, Michael. > This patch adds support for returning per entry/per reference/per partial result controls. The LDAPObject result3 method is extended with 3 additional and optional arguments: def result3(self,msgid=ldap.RES_ANY,all=1,timeout=None,add_ctrls=0,add_intermediates=0,add_extop=0): add_ctrls - if this is non-zero, per entry/ref/intermediate controls will be added to the tuple representing each item for entries, this will be (dn, entrydata, controllist) where controllist is a List of control tuples, each one consisting of the string oid, the boolean iscrit, and the control value - for references, this will be a tuple consisting of None, the list of references, and the controllist - for partial/intermediate results, this will be a tuple consisting of the msgtype (LDAP_RES_INTERMEDIATE), the returned oid, the returned value, and the control list add_intermediates - if this is non-zero, intermediate/partial result responses to extended operations will be processed - this could be useful for implementing a LDAPSync client add_extop - if this is non-zero, extended operation results will be returned (which I don't think is very useful now, since python-ldap does not support calling ldap_extended_operation(_s) directly) - this changes the tuple returned by result3 to include two additional items - the extended operation response oid, and the extended operation response value With this, I was able to successfully use the Dereference Control with 389. I tested like this, on RHEL5 x86_64, with openldap 2.3 installed (and python-ldap, but I was able to use my local one instead): python setup.py build PYTHONPATH=build/lib.linux-x86_64-2.4:/share/scripts python /share/scripts/dereftest.py -------------- next part -------------- A non-text attachment was scrubbed... Name: entrycontrols.patch Type: text/x-patch Size: 14957 bytes Desc: not available URL: From jahidul.hasan at bjitgroup.com Mon Nov 15 06:16:46 2010 From: jahidul.hasan at bjitgroup.com (Jahidul Hasan) Date: Mon, 15 Nov 2010 14:16:46 +0900 (JST) Subject: How to find groups(CN) which contains specific words? Message-ID: <22611.124.215.201.5.1289798206.squirrel@jp.bjitgroup.com> Hi I need to find those groups name which contains the word "ABC", is it possible ? base_dn = 'CN=ABC,OU=Common,DC=test,DC=com' ldapConn.search_s(base_dn, ldap.SCOPE_SUBTREE) Can I use %ABC% ? Regards Jahid From zhbmaillistonly at gmail.com Wed Dec 15 01:32:45 2010 From: zhbmaillistonly at gmail.com (Zhang Huangbin) Date: Wed, 15 Dec 2010 08:32:45 +0800 Subject: How to find groups(CN) which contains specific words? In-Reply-To: <22611.124.215.201.5.1289798206.squirrel@jp.bjitgroup.com> References: <22611.124.215.201.5.1289798206.squirrel@jp.bjitgroup.com> Message-ID: <6E277852-07BF-4FA7-80BE-9FE6A0609752@gmail.com> On Nov 15, 2010, at 1:16 PM, Jahidul Hasan wrote: > I need to find those groups name which contains the word "ABC", is it > possible ? > > base_dn = 'CN=ABC,OU=Common,DC=test,DC=com' > ldapConn.search_s(base_dn, ldap.SCOPE_SUBTREE) > > Can I use %ABC% ? LDAP search filter can be wild-card, use '*ABC*' instead. Reference: http://www.zytrax.com/books/ldap/apa/search.html -- Zhang Huangbin - Open Source Mail Server Solution for Red Hat(R) Enterprise Linux, CentOS, Debian, Ubuntu, OpenSuSE, FreeBSD: http://www.iredmail.org/ From michele.marcionelli at math.ethz.ch Tue Dec 14 22:34:48 2010 From: michele.marcionelli at math.ethz.ch (Michele Marcionelli) Date: Tue, 14 Dec 2010 22:34:48 +0100 Subject: How to find groups(CN) which contains specific words? In-Reply-To: <22611.124.215.201.5.1289798206.squirrel@jp.bjitgroup.com> References: <22611.124.215.201.5.1289798206.squirrel@jp.bjitgroup.com> Message-ID: Hello Jahid try with "(cn=*abc*)". This works fine with ldapsearch. Kind regards, Michele On Nov 15, 2010, at 6:16 , Jahidul Hasan wrote: > Hi > > I need to find those groups name which contains the word "ABC", is it > possible ? > > base_dn = 'CN=ABC,OU=Common,DC=test,DC=com' > ldapConn.search_s(base_dn, ldap.SCOPE_SUBTREE) > > Can I use %ABC% ? > > Regards > Jahid > > > From michael at stroeder.com Wed Dec 15 19:30:57 2010 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 15 Dec 2010 19:30:57 +0100 Subject: How to find groups(CN) which contains specific words? In-Reply-To: <6E277852-07BF-4FA7-80BE-9FE6A0609752@gmail.com> References: <22611.124.215.201.5.1289798206.squirrel@jp.bjitgroup.com> <6E277852-07BF-4FA7-80BE-9FE6A0609752@gmail.com> Message-ID: <4D090961.5090100@stroeder.com> Zhang Huangbin wrote: > On Nov 15, 2010, at 1:16 PM, Jahidul Hasan wrote: >> I need to find those groups name which contains the word "ABC", is it >> possible ? >> >> base_dn = 'CN=ABC,OU=Common,DC=test,DC=com' >> ldapConn.search_s(base_dn, ldap.SCOPE_SUBTREE) >> >> Can I use %ABC% ? Not in base_dn. > LDAP search filter can be wild-card, use '*ABC*' instead. > > Reference: http://www.zytrax.com/books/ldap/apa/search.html The code snippet of the original poster above does not contain a search filter at all. So additionally he should read: http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.search ldapConn.search_s(base_dn, ldap.SCOPE_SUBTREE,filterstr='cn=*abc*') Ciao, Michael. From zhbmaillistonly at gmail.com Wed Oct 27 16:43:14 2010 From: zhbmaillistonly at gmail.com (Zhang Huangbin) Date: Wed, 27 Oct 2010 22:43:14 +0800 Subject: Can't install python-ldap from pypi.python.org Message-ID: <29DE67E4-5671-4E20-AE44-86CE5A97288B@gmail.com> Hi, developers. I can't install python-ldap from pypi.python.org, will you consider fixing it? First of all, there's a compile issue with py-ldap-2.3.12 on RHEL/CentOS 5.x: http://marc.info/?t=128152313400002&r=1&w=2 Old versions are not available: #---<--- # easy_install python-ldap==2.3.11 Searching for python-ldap==2.3.11 Reading http://cheeseshop.python.org/pypi/python-ldap/ Reading http://www.python-ldap.org/ Reading http://cheeseshop.python.org/pypi/python-ldap/2.3.12 No local packages or download links found for python-ldap==2.3.11 error: Could not find suitable distribution for Requirement.parse('python-ldap==2.3.11') # easy_install python-ldap==2.3.10 Searching for python-ldap==2.3.10 Reading http://cheeseshop.python.org/pypi/python-ldap/ Reading http://www.python-ldap.org/ Reading http://cheeseshop.python.org/pypi/python-ldap/2.3.12 No local packages or download links found for python-ldap==2.3.10 error: Could not find suitable distribution for Requirement.parse('python-ldap==2.3.10') # easy_install python-ldap==2.3.9 Searching for python-ldap==2.3.9 Reading http://cheeseshop.python.org/pypi/python-ldap/ Reading http://www.python-ldap.org/ Reading http://cheeseshop.python.org/pypi/python-ldap/2.3.12 No local packages or download links found for python-ldap==2.3.9 error: Could not find suitable distribution for Requirement.parse('python-ldap==2.3.9') #---<--- From marc.patermann at ofd-z.niedersachsen.de Wed Nov 10 12:58:38 2010 From: marc.patermann at ofd-z.niedersachsen.de (Marc-Boris Patermann) Date: Wed, 10 Nov 2010 12:58:38 +0100 Subject: python-ldap Frage zu LDIF Message-ID: <4CDA88EE.2020601@ofd-z.niedersachsen.de> Hallo Michael, ich habe ein Frage zum Python-Modul LDAP bzw. der LDIFParser Klasse. [Meine Python-Kenntnisse sind noch nicht sehr tiefgreifend.] Wo legt LDIFParser.parse() denn die Eintr?ge ab? Bei LDIFRecordList gibt es ein Array, das die Eintr?ge enth?lt. >>> ldif_parser = ldif.LDIFRecordList(open("input.ldif"),max_entries=1) >>> ldif_parser.parse() >>> ldif_parser.all_records[0] Ich versuche eigentlich nur einen slapcat-Output (relativ gro?) als LDIF einzulesen, bestimmte Eintr?ge (viele) zu ver?ndern und das ver?nderte Ergebnis wegzuschreiben, aber es gelingt mir - wie gesagt - nicht. Vielleicht hast du ja einen Hinweis f?r mich. Danke im voraus! Mit freundlichen Gr??en -- Marc-Boris Patermann IuK 355 OFD Niedersachsen Tel. 0511/101-3456 Waterloostr. 5 Fax. 0511/101-3016 30169 Hannover From michael at stroeder.com Wed Nov 10 13:12:07 2010 From: michael at stroeder.com (=?ISO-8859-15?Q?Michael_Str=F6der?=) Date: Wed, 10 Nov 2010 13:12:07 +0100 Subject: python-ldap Frage zu LDIF In-Reply-To: <4CDA88EE.2020601@ofd-z.niedersachsen.de> References: <4CDA88EE.2020601@ofd-z.niedersachsen.de> Message-ID: <4CDA8C17.2060508@stroeder.com> Marc-Boris Patermann wrote: > ich habe ein Frage zum Python-Modul LDAP bzw. der LDIFParser Klasse. > [Meine Python-Kenntnisse sind noch nicht sehr tiefgreifend.] Hmm, pers?nlich an mich interessierte Fragen habe ich meist nicht so gerne. Am besten solche Fragen zu python-ldap auf der Mailing-Liste python-ldap-dev (englisch), in news:comp.lang.python (englisch) oder news:de.comp.lang.python (deutsch) stellen Ich lese dort ?berall auch mit. Aber sei's drum... > Wo legt LDIFParser.parse() denn die Eintr?ge ab? Nirgends. ;-) Letztlich leitet man eine eigene Parser-Klasse MyLDIFParser von der Klasse LDIFParser ab und implementiert in der Methode MyLDIFParser.handle(self,dn,entry) die ben?tigte Funktionalit?t. Die Methode parse() startet dann den Vorgang. Hier hat es auch ein kleines Beispiel: http://www.python-ldap.org/doc/html/ldif.html#example Das kopiert eine LDIF-Datei und l?sst einige Eintr?ge dabei weg. (Das Beispiel ist eigentlich schlecht programmiert...) > Bei LDIFRecordList gibt es ein Array, das die Eintr?ge enth?lt. >>>> ldif_parser = ldif.LDIFRecordList(open("input.ldif"),max_entries=1) >>>> ldif_parser.parse() >>>> ldif_parser.all_records[0] > > Ich versuche eigentlich nur einen slapcat-Output (relativ gro?) als LDIF > einzulesen, bestimmte Eintr?ge (viele) zu ver?ndern und das ver?nderte > Ergebnis wegzuschreiben, aber es gelingt mir - wie gesagt - nicht. LDIFRecordList kann dazu dienen, relativ kleine LDIF-Daten mal eben schnell in eine Liste einzulesen. Ist aber nicht f?r einen grossen LDIF-Export und Stream-Processing gedacht. Ciao, Michael. From vitaliypodoba at gmail.com Fri Nov 19 23:14:56 2010 From: vitaliypodoba at gmail.com (Vitaliy Podoba) Date: Fri, 19 Nov 2010 22:14:56 +0000 (UTC) Subject: LDAP attribute syntaxes to python data types conversion Message-ID: Hi, LDAP natively supports a lot of different types of syntaxes for it's attributes in schemas, like syntaxes for strings, booleans, dates, integers, numbers, etc... But python-ldap queries always return utf-8 encoded strings for any type of ldap attribute syntax. So this way in my application to properly handle, for example, boolean ldap attribute syntax I'm usually doing: if ldap_value == 'TRUE': value = True elif ldap_value == 'FALSE' value = False I'm pretty new to LDAP development so don't know a lot about it's history and design decisions made during it's development. So I'm just wondering why python-ldap doesn't benefit from those LDAP attribute syntax definitions and performs conversion to python data types when possible but always returns strings. Was this discussed previously? I can't google any relevant information on this topic. Any hints, links, suggestions, insights will be highly appreciated! Regards, Vitaliy Podoba