Skip to main content
February 4, 2009
Answered

CFLDAP Filter by OU

  • February 4, 2009
  • 2 replies
  • 1696 views
Hello,

I have this CFLDAP query that returns all of the users in my AD from every OU but excluding disabled accounts. It works fine...

However what I would like to do is return all of the users from a particular OU only, i`m sure i need to do this in the filter attribute but I cant figure it out. I have three OU`s. I only want to query the users in my "People" OU. Any ideas how I specify this?

Here is my code.
Thanks.

<cfldap action="QUERY"
name="results"
attributes="userPrincipalName,description,physicalDeliveryOfficeName"
start="dc=domain,dc=com
scope="SUBTREE"
filter="(&(objectCategory=user)(userPrincipalName=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))"
server="server.domain"
username="********"
password="********">

<cfdump var="#results#">



This topic has been closed for replies.
Correct answer
Ive solved it.

I placed "OU=Peoplae" in the "start" attribute, here...

start="ou=People,dc=redditch,dc=vd,dc=valeo"

I did try taking out the other gibberish like you suggested but still it didnt return anythng, strange becuase it really should have.

Thanks your your help.

2 replies

tclaremont
Inspiring
February 4, 2009
Take out the other gibberish.

Replace this:
filter=(&(objectCategory=user)(OU=People)(userPrincipalName=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))"

With this:
filter = "OU=people"

Do you get anything back?

Correct answer
February 5, 2009
Ive solved it.

I placed "OU=Peoplae" in the "start" attribute, here...

start="ou=People,dc=redditch,dc=vd,dc=valeo"

I did try taking out the other gibberish like you suggested but still it didnt return anythng, strange becuase it really should have.

Thanks your your help.
tclaremont
Inspiring
February 4, 2009
Doesn't this work?

filter = "OU=people"
February 4, 2009
No, I tried it like this.....

filter=(&(objectCategory=user)(OU=People)(userPrincipalName=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))"

I`m really not sure if i`m putting "OU=People" in the right place and I dont know if the syntax is correct.