Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very Newbe Question re LDAP searching 1

Status
Not open for further replies.

coch

Technical User
Jul 4, 2002
106
GB
I'm trying to use lpd.exe. What I'm trying to do is define a search filter so that it will find all users that have the # character in the Alias (mailNickname)box in AD and all users that do not have a a mailstore so somehting like homeMDB not present


Am I using teh right program ?? When I get the search string can it be run from a cmd??

Can any help or point me the direction of a few sites that could

Many thanks
 
Hello there ...

If you are fairly technical you can read through RFC 2254 for search filter syntaxes at
Additionally you can run something that is a little more flexible than ldp.exe, and do it from the command line - that would be the ldapsearch program available in an LDAP SDK (you can google to find the correct site).

If you like a GUI - try Jarek's LDAP Browser tool - it's free but does require java.

To address the meat of your question:

You can wildcard your searches - and will get correct results provided you have permission to search for the attribute and the attribute is properly indexed.

To search for the "#" character in mailNickname you would do the following:
(mailNickname=*#*)

To search for the absence of something you would do the following:
(!(homeMDB=*))

To combine the two:
(&(mailNickname=*#*)(!(homeMDB=*)))

HTH



-Chris Larivee
 
Thanks for the reply!

It worked great many thanks, so would this pull all objects except the ones that have # in the mail nickname and don't have a homeMDB?

(&(cn=*)(mailNickname=*#*)(!(homMDB=*))))
 
There is an extra ) in that expression. Additionally it will pull the following:

Entries that have a cn value
Entries that have a value of # in mailNickname
Entries that do not have a homMDB attribute

(BTW you may want to switch homMDB to homeMDB if you are searching Active Directory (unless you have customized schema with homMDB)).

If you wanted to pull all objects that do not have a homeMDB or # in their value it would look like:

(&(cn=*)(!(mailNickname=*#*))(!(homeMDB=*)))

HTH

-Chris Larivee
 
ok I think I'm getting the picture a little bit now but I think I'm going the wrong way around it. What i want to do is to run this search that will pull all user objects unless they have a # in mailNickname or they don't have a homeMDB. So i think i'm looking for an exception statement if there is such a thing??

Ideally search would (&(cn=*) except if(!(mailNickname=*#*))(!(homeMDB=*)))
Does this make snese?
 
OR - that is the part I was missing before.

Let's review:

You want to retreive all users who have a mailNickname with no # symbol in it or all users who have no homeMDB

If yes then the actual expression changes a little - using the OR operator | for ldap searches.

(&(cn=*)(|(!(mailNickname=*#*))(!(homeMDB=*))))

Remember - with this search it will return entries that have a homeMDB because it evaluates the mailNickname to be true. It also follows it will return mailNicknames with # because homeMDB is not present. Make sense?

If you want them to fit both criteria then it would be the expression from my last post:

(&(cn=*)(!(mailNickname=*#*))(!(homeMDB=*)))

Best of luck ...

-Chris Larivee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top