?
Solved

Query quandries with LDAP sql dialect syntax for Active Directory

Posted on 2005-03-16
4
Medium Priority
?
548 Views
Last Modified: 2012-05-05
I am using asp.net to get to the Active Directory GAL for Windows 2003 and Exchange information.

1)  is the OR operator with parenthesis supported in the SQL dialect of LDAP?
This works but results don't reflect the msExchHideFromAddressLists or mail criteria:
   strQuery = "SELECT cn,telephoneNumber,physicalDeliveryOfficeName,title,company,sn,objectClass, " _
& "from 'LDAP://MYSERVERl' "  _
& "where  objectClass='user'  or  objectClass='group'  and msExchHideFromAddressLists<>TRUE and mail='*' "  _
& "order by cn"

But this doesn't work and returns an error:
   strQuery = "SELECT cn,telephoneNumber,physicalDeliveryOfficeName,title,company,sn,objectClass, " _
& "from 'LDAP://MYSERVER' "  _
& "where  (objectClass='user'  or  objectClass='group')  and msExchHideFromAddressLists<>TRUE and mail='*' "  _
& "order by cn"

2) And how do I limit the query to truly just 'users'?
My results above return more than just Objectclass=User, computer accounts are also included.  
In ActiveDirectory Users and Computers, on a computer object on the 'Object' tab reports it as: "Computer"
BUT in ADSI that same object reports values in an array style list - the top one is 'computer' but the full list includes others:
Computer
OrganizationalPerson
Person
top
user

0
Comment
Question by:thefumbler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 13564535
1) Yes.
The error might because of unsupported attribute used in the criteria isn'by object returned from the query.

2) Try
SELECT [field list...]
FROM [yourAdsPath]
WHERE
     objectCategory='person' AND objectClass='user' msExchHideFromAddressLists<>TRUE AND mail='*'
ORDER BY cn
0
 
LVL 1

Author Comment

by:thefumbler
ID: 13567130
jhenry, your solution to #2 works great.  

I don't quite understand #1 though - can you elaborate?  Do you mean that I must also use the criteria in the field list of any LDAP query?
0
 
LVL 20

Accepted Solution

by:
ihenry earned 1600 total points
ID: 13581573
Some typos in my previous post, sorry for the confusion. What I meant with the unsupported attribute is that, your search might be returning some objects that do not support msExchHideFromAddressLists attribute. For example, group object as it is spesified in the search criteria. I think msExchHideFromAddressLists attribute isn't supported by object class other than person, user or contact. I could be wrong, though.
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question