I think you may need to put the entire distinguished  name in for the OU. I
ran into a similiar problem trying to write a filter to exclude a group from
an Exchange thing. 

something like
(&(objectClass=organizationalUnit)(!ou=OU=foo,OU=man,DC=chu,DC=net)) 

MY 2 cents FWIW.

Brian

 -----Original Message-----
From: Tony Murray [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 24, 2002 11:02 AM
To: [EMAIL PROTECTED]
Subject: Re: [ActiveDir] Searching LDAP


Hi Brendan

I could be wrong, but I don't believe you can do this with a single ldap
query.  Your attempts failed because the objectClass of "user" specified in
your filter there is no OU attribute.  

The way I would do it is to run a query to return all the OUs you are
interested in and then step the results with your user query.  In other words
start with a query like this:

(&(objectClass=organizationalUnit)(!ou=Contacts))

Return the organizationalUnit attribute.  Subtree search from the top.

Then run your original query against each of the returned OUs in turn.

I have a script that does something similar.  Mail me off-list if you want to
see it.

Tony
www.activedir.org

---------- Original Message ----------------------------------
From: "Stephens, Brendan" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: Fri, 24 May 2002 10:21:40 -0400

If anyone is familiar with LDAP syntax, I could use some help on this one...

Our directory structure is separated into OU's, and I am trying to filter a
specific OU out of the picture...

I can pull the users by using the following syntax for ADO...
strSQL = "<LDAP://"; & Domain
&">;(&(objectClass=user)(objectCategory=person)(sn=*);samAccountName,name,co
mpany,telephoneNumber,AdsPath;subtree"

But how do I filter out an OU? (Contacts)

I have tried:

strSQL = "<LDAP://"; & Domain
&">;(&(objectClass=user)(objectCategory=person)(sn=*)(!ou=*Contacts*);samAcc
ountName,name,company,telephoneNumber,AdsPath;subtree"

and a couple of other variants on this, but to no avail...

Any suggestions or guru's on this matter?

Brendan Stephens
Web Applications Developer
Tech-Advances

List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to