Any example of Server/Client Side Sorting?
Hi, all.
Does anyone has working code snippet of server/client side sorting?
I use serverctrls in search_ext_s() like this:
search_ext_s(, serverctrls = [
ldap.controls.LDAPControl('1.2.840.113556.1.4.473',1,None) ],)
got error msg:
UNAVAILABLE_CRITICAL_EXTENSION: {'info': 'critical extension is not
recognized', 'desc': 'Critical extension is unavailable'}
* Use clientctrls:
search_ext_s(, clientctrls = [
ldap.controls.LDAPControl('1.2.840.113556.1.4.473',1,None) ],)
got error msg:
NOT_SUPPORTED: {'info': '', 'desc': 'Not Supported'}
My os is Ubuntu 9.04, OpenLDAP-2.4.15-1ubuntu3.
--
Best regards.
Zhang Huangbin
- Open Source Mail Server Solution for RHEL, CentOS, Debian:
http://code.google.com/p/iredmail/
--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Zhang Huangbin wrote:
>
> Does anyone has working code snippet of server/client side sorting?
>
> I use serverctrls in search_ext_s() like this:
>
> search_ext_s(, serverctrls = [
> ldap.controls.LDAPControl('1.2.840.113556.1.4.473',1,None) ],)
>
> got error msg:
>
> UNAVAILABLE_CRITICAL_EXTENSION: {'info': 'critical extension is not
> recognized', 'desc': 'Critical extension is unavailable'}
>
> * Use clientctrls:
>
> search_ext_s(, clientctrls = [
> ldap.controls.LDAPControl('1.2.840.113556.1.4.473',1,None) ],)
>
> got error msg:
>
> NOT_SUPPORTED: {'info': '', 'desc': 'Not Supported'}
>
> My os is Ubuntu 9.04, OpenLDAP-2.4.15-1ubuntu3.
The error message is pretty clear: This particular LDAP server does not
support server-side sorting.
Besides that you should read RFC 2891 to learn how to generate the
controlValue which specifies which attribute and matching rule
(optional) is used for sorting and whether you want reverse order
(optional). You could try to generate the controlValue with module pyasn1.
Ciao, Michael.
--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Michael Ströder wrote: > > The error message is pretty clear: This particular LDAP server does not > support server-side sorting. > I checked the rootdse, neither server side sort nor client side sort is supported: supportedControl: 2.16.840.1.113730.3.4.18 supportedControl: 2.16.840.1.113730.3.4.2 supportedControl: 1.3.6.1.4.1.4203.1.10.1 supportedControl: 1.2.840.113556.1.4.319 supportedControl: 1.2.826.0.1.3344810.2.3 supportedControl: 1.3.6.1.1.13.2 supportedControl: 1.3.6.1.1.13.1 supportedControl: 1.3.6.1.1.12 supportedExtension: 1.3.6.1.4.1.1466.20037 supportedExtension: 1.3.6.1.4.1.4203.1.11.1 supportedExtension: 1.3.6.1.4.1.4203.1.11.3 supportedExtension: 1.3.6.1.1.8 > Besides that you should read RFC 2891 to learn how to generate the > controlValue which specifies which attribute and matching rule > (optional) is used for sorting and whether you want reverse order > (optional). You could try to generate the controlValue with module pyasn1. Got it. Thanks Michael :) -- Best regards. Zhang Huangbin - Open Source Mail Server Solution for RHEL, CentOS, Debian: http://code.google.com/p/iredmail/ -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Zhang Huangbin wrote: > Michael Ströder wrote: >> The error message is pretty clear: This particular LDAP server does not >> support server-side sorting. > > I checked the rootdse, neither server side sort nor client side sort is > supported: 1. Client-side sorting is done within the client libs if supported. So it wouldn't be listed in the attribute 'supportedControl' of the DSA's rootDSE anyway. Not sure whether client controls are used in OpenLDAP's libldap at all. 2. One should always try out whether a DSA supports a particular control within a certain naming context. E.g. former versions of OpenLDAP supported the Tree Deletion Control only for naming contexts served by back-sql. Feature detection is not that easy. > supportedControl: 2.16.840.1.113730.3.4.18 > supportedControl: 2.16.840.1.113730.3.4.2 > supportedControl: 1.3.6.1.4.1.4203.1.10.1 > supportedControl: 1.2.840.113556.1.4.319 > supportedControl: 1.2.826.0.1.3344810.2.3 > supportedControl: 1.3.6.1.1.13.2 > supportedControl: 1.3.6.1.1.13.1 > supportedControl: 1.3.6.1.1.12 > supportedExtension: 1.3.6.1.4.1.1466.20037 > supportedExtension: 1.3.6.1.4.1.4203.1.11.1 > supportedExtension: 1.3.6.1.4.1.4203.1.11.3 > supportedExtension: 1.3.6.1.1.8 Everyone tired of looking up the OIDs should use my http://web2ldap.de since it contains a registry of OIDs with descriptions of the meaning which are displayed when displaying the rootDSE. Ciao, Michael. -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Michael Ströder wrote: > > 1. Client-side sorting is done within the client libs if supported. So > it wouldn't be listed in the attribute 'supportedControl' of the DSA's > rootDSE anyway. Not sure whether client controls are used in OpenLDAP's > libldap at all. > Any exist python module/function to sort ldap search results? > 2. One should always try out whether a DSA supports a particular control > within a certain naming context. E.g. former versions of OpenLDAP > supported the Tree Deletion Control only for naming contexts served by > back-sql. > > Feature detection is not that easy. > I also need function to delete ldap tree too, and reading your web2ldap/pylib/ldapsession.py now. > Everyone tired of looking up the OIDs should use my http://web2ldap.de > since it contains a registry of OIDs with descriptions of the meaning > which are displayed when displaying the rootDSE. I found it moment ago. :) Tring to learn ldap programing from web2ldap now. Thanks for your great program. :) -- Best regards. Zhang Huangbin - Open Source Mail Server Solution for RHEL, CentOS, Debian: http://code.google.com/p/iredmail/ -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Zhang Huangbin wrote: > Michael Ströder wrote: >> 1. Client-side sorting is done within the client libs if supported. So >> it wouldn't be listed in the attribute 'supportedControl' of the DSA's >> rootDSE anyway. Not sure whether client controls are used in OpenLDAP's >> libldap at all. > > Any exist python module/function to sort ldap search results? Well, why do you really need that? I don't have client-side sorting in web2ldap because it won't scale with large search results. Some of my customers have more than 100k person/user entries in their directories. >> 2. One should always try out whether a DSA supports a particular control >> within a certain naming context. E.g. former versions of OpenLDAP >> supported the Tree Deletion Control only for naming contexts served by >> back-sql. >> >> Feature detection is not that easy. > > I also need function to delete ldap tree too, and reading your > web2ldap/pylib/ldapsession.py now. The function DelTree() is in pylib/w2lapp/delete.py. If the tree deletion control cannot or shall not be used it also makes use of some operational attributes (e.g. hasSubordinates etc.) to determine whether a found entry is a leaf-entry. > Tring to learn ldap programing from web2ldap now. Thanks for your great > program. :) Bear in mind that I started learning Python when the first code was written almost 11 years ago. So I have to admit that many parts are really ugly code and not really good programming examples. Ciao, Michael. -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Michael Ströder wrote: > Zhang Huangbin wrote: > >> Any exist python module/function to sort ldap search results? > > Well, why do you really need that? I don't have client-side sorting in > web2ldap because it won't scale with large search results. Some of my > customers have more than 100k person/user entries in their directories. > I have 100+ accounts in LDAP, but they are not listed orderly. like this: dn: mail=w...@xxx, dn: mail=w...@xxx, dn: mail=w...@xxx, dn: mail=...@xxx, I just want to make them listed orderly like this: dn: mail=...@xxx, dn: mail=w...@xxx, dn: mail=w...@xxx, dn: mail=w...@xxx, Do you make them listed in the original order? >> Tring to learn ldap programing from web2ldap now. Thanks for your great >> program. :) >> > > Bear in mind that I started learning Python when the first code was > written almost 11 years ago. So I have to admit that many parts are > really ugly code and not really good programming examples. Got it. thanks for your remind :) -- Best regards. Zhang Huangbin - Open Source Mail Server Solution for RHEL, CentOS, Debian: http://code.google.com/p/iredmail/ -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Zhang Huangbin wrote: > Michael Ströder wrote: >> Zhang Huangbin wrote: >> >>> Any exist python module/function to sort ldap search results? >> Well, why do you really need that? I don't have client-side sorting in >> web2ldap because it won't scale with large search results. Some of my >> customers have more than 100k person/user entries in their directories. >> > > I have 100+ accounts in LDAP, but they are not listed orderly. 100+ entries are not so many. So you could try sorting the list of search results retrieved with LDAPObject.ldap_search_ext_s() by invoking list method .sort(). Make sure you understand how to control the comparisons. See item 8. here: http://docs.python.org/library/stdtypes.html#index-591 Ciao, Michael. -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Michael Ströder wrote: > > 100+ entries are not so many. So you could try sorting the list of > search results retrieved with LDAPObject.ldap_search_ext_s() by invoking > list method .sort(). Make sure you understand how to control the > comparisons. > > See item 8. here: > http://docs.python.org/library/stdtypes.html#index-591 > No idea yet. Any example? Thanks :) -- Best regards. Zhang Huangbin - Open Source Mail Server Solution for RHEL, CentOS, Debian: http://code.google.com/p/iredmail/ -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Zhang Huangbin wrote: > Michael Ströder wrote: >> 100+ entries are not so many. So you could try sorting the list of >> search results retrieved with LDAPObject.ldap_search_ext_s() by invoking >> list method .sort(). Make sure you understand how to control the >> comparisons. >> >> See item 8. here: >> http://docs.python.org/library/stdtypes.html#index-591 >> > > No idea yet. Any example? Bear in mind search results returned by synchronous search methods are in a list of 2-tuples each consisting of the DN string and the entry dictionary like this: [(dn,entry)] Without testing just as food for thought: Compare function for case-insensitive comparison of the DN: cmp=lambda x,y: cmp(x[0].lower(), y[0}.lower()) Compare function for case-insensitive comparison of the first attribute value of 'cn' (this would choke with KeyError exception if there's no attribute 'cn' in the entry): cmp=lambda x,y: cmp(x[1]['cn'][0].lower(), y[1]['cn'][0].lower()) And then results.sort(cmp). I don't know how fast this is though. The rest of the homework is up to you. For various list sorting aspects you should ask in news:comp.lang.python Ciao, Michael. -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Michael Ströder wrote: > Zhang Huangbin wrote: >> Michael Ströder wrote: >> Tring to learn ldap programing from web2ldap now. Thanks for your great >> program. :) > > Bear in mind that I started learning Python when the first code was > written almost 11 years ago. So I have to admit that many parts are > really ugly code and not really good programming examples. Every programmer I've ever talked to always thinks their own code sucks. -- Russell A. Jackson Network Analyst California State University, Bakersfield With a gentleman I try to be a gentleman and a half, and with a fraud I try to be a fraud and a half. -- Otto von Bismarck signature.asc Description: OpenPGP digital signature -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Any example of Server/Client Side Sorting?
Michael Ströder wrote: > > Compare function for case-insensitive comparison of the DN: > > cmp=lambda x,y: cmp(x[0].lower(), y[0}.lower()) > > Thanks Michael. :) I tried this compare function, but got this err msg: RuntimeError: maximum recursion depth exceeded The result contains less than 10 records. -- Best regards. Zhang Huangbin - Open Source Mail Server Solution for RHEL, CentOS, Debian: http://code.google.com/p/iredmail/ -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
