novice LDAP query help

J

Joe Murphy

Wondering if anyone can help me write a pretty basic LDAP query for an LDAP
novice.

Wanted to return all computers whose cn begins with either NARM or EUUK

This is what I have so far and it isn't working
(|(cn=euuk*) (cn=narm*))

Thanks,
JM
 
E

Enkidu

Wondering if anyone can help me write a pretty basic LDAP query for an LDAP
novice.

Wanted to return all computers whose cn begins with either NARM or EUUK

This is what I have so far and it isn't working
( | (cn=euuk*) (cn=narm*) )
In what way is it not working? Is it not returning any results, or is
it giving too many results?

Have you tried each part separately?

Cheers,

Cliff
 
J

Joe Richards [MVP]

Close...

(&(objectCategory=computer)(|(cn=euuk*)(cn=narm*)))

forgot the OR (|) for the names.


joe
 
J

Joe Murphy

Hi Joe,

Funny it should be you to reply to my query help. I'm using oldcmp.exe to
try and disable/delete computers, but I don't want to disable/delete any
whose name starts with euuk or narm

I ran:
oldcmp -age 0 -af (&(objectCategory=computer)(|(cn=euuk*)(cn=narm*))) -h
nahqdcs2.mycorp.com -report

and I get the error:
( was unexpected at this time.
 
J

Joe Richards [MVP]

I'm funny like that. :blush:P

You are using -af which is to ADD to the default filter and what you probably
wanted was -f to replace the filter though that would work as a -af filter, it
would just be a bit redundant. The main reason that specifically didn't work is
that you didn't quote the af string and the & told the command interpreter you
had two commands on one line.

For instance you can do

net stop alerter & net start alerter

The & splits the commands and says do the first and then do the second.



Anyway to this with -af you would want to specify something like

-af "(&(!(cn=euuk*))(!(cn=narm*)))"

You actually want to exclude those names so you need to look for the NOT of them.

joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top