From: Timothy W. <wi...@vi...> - 2000-06-23 18:23:52
|
Hi everyone, I'm making good progress implementing Jeffrey Shell's ZLDAP product. I've got it printing an employee directory using data from our NDS server. I've read David Leonard's "Python LDAP Module Reference," but there are a couple things I don't understand. 1. What's the syntax for doing more complex filtering of search results in a "search_s" operation. I saw the reference to BNF in David's docs, and I had to look up what BNF meant. Unfortunately, I haven't been able to figure out how to filter my searches for two different attribute variables simultaneously. Would someone be kind enough to provide a couple concrete examples. Here's the type of thing I'm looking for: Filter for --> objectclass=person AND sn=Wilson It looks like once I understand the "and," the "or" and "not" should be obvious. 2. Is there any way to sort the results of the search other than doing a separate python operation of the search result. (I haven't tried it, but I assume you could have python sort the results.) Thanks in advance for any help. I think I'm going to be using python-ldap quite a bit. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ wi...@vi... | <dtml-var pithy_quote> | http://linux.com/ |
From: Gene Yu <ge...@si...> - 2000-06-23 18:52:50
|
Timothy, The filter you're looking for would look like this: (&(objectclass=person)(sn=Wilson)) You'll have to sort the results in Python. Gene On Fri, 23 Jun 2000, Timothy Wilson wrote: > Hi everyone, > > I'm making good progress implementing Jeffrey Shell's ZLDAP product. I've > got it printing an employee directory using data from our NDS server. I've > read David Leonard's "Python LDAP Module Reference," but there are a couple > things I don't understand. > > 1. What's the syntax for doing more complex filtering of search results in a > "search_s" operation. I saw the reference to BNF in David's docs, and I had > to look up what BNF meant. Unfortunately, I haven't been able to figure out > how to filter my searches for two different attribute variables > simultaneously. Would someone be kind enough to provide a couple concrete > examples. Here's the type of thing I'm looking for: > > Filter for --> objectclass=person AND sn=Wilson > > It looks like once I understand the "and," the "or" and "not" should be > obvious. > > 2. Is there any way to sort the results of the search other than doing a > separate python operation of the search result. (I haven't tried it, but I > assume you could have python sort the results.) > > Thanks in advance for any help. I think I'm going to be using python-ldap > quite a bit. > > -Tim > > -- > Tim Wilson | Visit Sibley online: | Check out: > Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ > W. St. Paul, MN | | http://slashdot.org/ > wi...@vi... | <dtml-var pithy_quote> | http://linux.com/ > > > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > http://lists.sourceforge.net/mailman/listinfo/python-ldap-dev > |
From: Timothy W. <wi...@vi...> - 2000-06-23 19:45:02
|
On Fri, 23 Jun 2000, Gene Yu wrote: > The filter you're looking for would look like this: > > (&(objectclass=person)(sn=Wilson)) Thanks. That worked perfectly. > > It looks like once I understand the "and," the "or" and "not" should be > > obvious. OK, I was wrong. I'm stumped as to how to combine boolean operators. How about two more examples? :-) 1. How would I search objectclass=person and return all records for people with sn=Wilson, but not givenName=Tim? 2. Search objectclass=person and return all records for people with st=MN OR st=IA, but not givenName=Tim? (A rather useless search I realize.) Thanks for the help. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ wi...@vi... | <dtml-var pithy_quote> | http://linux.com/ |
From: Jeffrey C. O. <je...@ol...> - 2000-06-23 20:15:55
|
On Fri, Jun 23, 2000 at 02:41:00PM -0500, Timothy Wilson wrote: > > 1. How would I search objectclass=person and return all records for people > with sn=Wilson, but not givenName=Tim? (&(objectclass=person)(sn=Wilson)(!(givenName=Tim))) > 2. Search objectclass=person and return all records for people with st=MN OR > st=IA, but not givenName=Tim? (A rather useless search I realize.) (&(objectclass=person)(|(st=MN)(st=IA))(!(givenName=Tim))) See RFC 1558 for a complete description. Jeff |
From: David L. <dav...@cs...> - 2000-06-24 01:53:07
|
hi On Fri, 23 Jun 2000, Jeffrey C. Ollie typed thusly: > (&(objectclass=person)(|(st=MN)(st=IA))(!(givenName=Tim))) > See RFC 1558 for a complete description. note that RFC 1960 obsoletes 1558. -- David Leonard Dav...@cs... Dept of Comp. Sci. and Elec. Engg _ Room:78-640 Ph:+61 7 336 51187 The University of Queensland |+| http://www.csee.uq.edu.au/~leonard/ QLD 4072 AUSTRALIA ~` '~ E2A24DC6446E5779D7AFC41AA04E6401 Curses! - Mojo Jojo |
From: Gene Yu <ge...@si...> - 2000-06-23 21:26:03
|
On Fri, 23 Jun 2000, Timothy Wilson wrote: > > [...] > > 1. How would I search objectclass=person and return all records for people > with sn=Wilson, but not givenName=Tim? Timothy, You're using prefix notation, so you have the operator followed by however many arguments. Your example #1 would look like this: (&(sn=Wilson)(!(givenName=Tim))) > 2. Search objectclass=person and return all records for people with st=MN OR > st=IA, but not givenName=Tim? (A rather useless search I realize.) You can just add terms forever: (&(a=1)(b=2)(c=3)(!(d=4)) ...) I suggest you take a look at RFC 2254 - The String Representation of LDAP Search Filters: http://www.ietf.org/rfc/rfc2254.txt It has many examples. Gene |
From: Timothy W. <wi...@vi...> - 2000-06-23 21:48:13
|
On Fri, 23 Jun 2000, Gene Yu wrote: > I suggest you take a look at RFC 2254 - The String Representation of LDAP > Search Filters: > > http://www.ietf.org/rfc/rfc2254.txt > > It has many examples. Thanks to everyone who offered suggestions. I'll have a look at the RFCs. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ wi...@vi... | <dtml-var pithy_quote> | http://linux.com/ |