Thanks Joe.  I did use that MSDN article before I posted, but it didn't list the escape sequence for the space character.  Knowing what I know now, I probably should have pieced it together considering that %20 is the space character in a URL.
 
Interesting that 'user' is not a valid objectcategory.  When I had ADUC create the query for me, it automatically generated the filter that included objectCategory=user.  New Query / Custom Search / then Display Name Is Exactly (space character). 
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of joe
Sent: Tuesday, February 07, 2006 5:39 PM
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] DSQUERY filter for space character only

The tricky piece here is the space, the displayname=\20 mechanism would work as well as the very cute little query Dean posted of displayname<=!. Check out http://msdn.microsoft.com/library/default.asp?url="">. It talks a little about constructing queries.
 
The other thing that stuck out to me appears to have stuck out to you is the fact that everyone was using objectcategory=user. The user class isn't a valid objectcategory. Luckily AD figures that out for you and changes the query to objectcategory=person. However, that may not be the query the OP wanted because that will return matching users and contacts.
 
Since displayname is indexed, you could probably get away with the query (&(objectclass=user)(displayname=\20)). The tried and true test would be to submit that query up against (&(objectcategory=person)(objectclass=user)(displayname=\20)) or even (&(sAMAccountType=805306368)(displayname=\20)) with the STATS control and see what indexes get used, I would expect displayName generally.
 
I just did a trace and took a peek and the displayname=" " doesn't even get to the server, the client dumps it as a bad query before then.
 
 
--
O'Reilly Active Directory Third Edition - http://www.joeware.net/win/ad3e.htm 
 
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Aragon
Sent: Tuesday, February 07, 2006 2:19 PM
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] DSQUERY filter for space character only

Have you tried:
 
 (&(objectCategory=Person)(objClass=User)(displayName=\\ ))
 

David Aragon
Your ability to perceive a solution is limited
only by your understanding of the problem

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sitton Glen E
Sent: Tuesday, February 07, 2006 9:17 AM
To: ActiveDir@mail.activedir.org
Subject: [ActiveDir] DSQUERY filter for space character only

I need to run an obscure DSQUERY with a filter that finds displayNames with a value of a single space character.  I'm stumped.  I've tried every escape character possibility that I'm aware of.  I know how to find null values, but can't seem to query on a space character alone.  It hoses the ldap syntax.
 
When ADUC builds the ldap query itself, it fails:
 
    (&(objectCategory=user)(displayName=   ))
 
    The query filter ... is not a valid query string.
 
I've tried:
    " "
    ' '
    %20
    +
 and escaping it with a \ or a ^
 
Any ideas?
 
Thanks in advance,
- Glen
 

Reply via email to