Retrieving only non-hidden users

Retrieving only non-hidden users

Post by Jim » Wed, 09 Jul 2003 00:56:34



I've written an ldap query to retrieve an object using an
EmployeeID.  In same cases, user's have more than one
account and I only want the account that is not hidden in
the Outlook address book.  Unfortunately, when I try to
add this condition to the query, it always returns zero
results.  I'm guessing that the problem is that the
attribute is null in cases that the account is not hidden
but I can't find the correct syntax for the filter.

strQuery = "<LDAP://serverName/dc=myCompany,dc=com>;(&
(employeeID=" & EmployeeID & ")(!
msExchHideFromAddressLists=1));distinguishedName,msExchHid
eFromAddressLists;subtree"

 
 
 

Retrieving only non-hidden users

Post by Jim » Wed, 09 Jul 2003 00:56:34


I've written an ldap query to retrieve an object using an
EmployeeID.  In same cases, user's have more than one
account and I only want the account that is not hidden in
the Outlook address book.  Unfortunately, when I try to
add this condition to the query, it always returns zero
results.  I'm guessing that the problem is that the
attribute is null in cases that the account is not hidden
but I can't find the correct syntax for the filter.

strQuery = "<LDAP://serverName/dc=myCompany,dc=com>;(&
(employeeID=" & EmployeeID & ")(!
msExchHideFromAddressLists=1));distinguishedName,msExchHid
eFromAddressLists;subtree"

 
 
 

Retrieving only non-hidden users

Post by Jim » Wed, 09 Jul 2003 00:56:34


I've written an ldap query to retrieve an object using an
EmployeeID.  In same cases, user's have more than one
account and I only want the account that is not hidden in
the Outlook address book.  Unfortunately, when I try to
add this condition to the query, it always returns zero
results.  I'm guessing that the problem is that the
attribute is null in cases that the account is not hidden
but I can't find the correct syntax for the filter.

strQuery = "<LDAP://serverName/dc=myCompany,dc=com>;(&
(employeeID=" & EmployeeID & ")(!
msExchHideFromAddressLists=1));distinguishedName,msExchHid
eFromAddressLists;subtree"

 
 
 

Retrieving only non-hidden users

Post by MVP - ADS » Wed, 09 Jul 2003 01:21:54


I'm pretty sure that attribute's syntax is Boolean.  Did you try:
(&(employeeID=" & EmployeeID & ")(!msExchHideFromAddressLists=TRUE));

Also, I don't think you want quotes around the employeeID attribute value
either unless it has quotes in it.  Those are not required for string
comparisons in LDAP filters.

Joe K.


Quote:> I've written an ldap query to retrieve an object using an
> EmployeeID.  In same cases, user's have more than one
> account and I only want the account that is not hidden in
> the Outlook address book.  Unfortunately, when I try to
> add this condition to the query, it always returns zero
> results.  I'm guessing that the problem is that the
> attribute is null in cases that the account is not hidden
> but I can't find the correct syntax for the filter.

> strQuery = "<LDAP://serverName/dc=myCompany,dc=com>;(&
> (employeeID=" & EmployeeID & ")(!
> msExchHideFromAddressLists=1));distinguishedName,msExchHid
> eFromAddressLists;subtree"

 
 
 

Retrieving only non-hidden users

Post by Jim » Wed, 09 Jul 2003 01:53:39


Yes, I did try the suggested syntax for booleans and it
does not work in this case.  Also, the quotation marks
around the employeeID are there because the EmployeeID is
a variable and I'm building the ldap string dynamically.  
The tricky part is that the value for
msExchHideFromAddressLists might be equal to false or it
might not exist.
 
 
 

Retrieving only non-hidden users

Post by MVP - ADS » Wed, 09 Jul 2003 02:50:16


Sorry.  My bad for pulling your code out of context and not really looking
at it.  How about this:

"(&(employeeID=" & EmployeeID & ")(!msExchHideFromAddressLists=TRUE))"

I did a quick test with the last clause and verified that it works for
values that are FALSE and values where the attribute is not populated.
Hopefully that will get you where you want.

Joe K.


Quote:> Yes, I did try the suggested syntax for booleans and it
> does not work in this case.  Also, the quotation marks
> around the employeeID are there because the EmployeeID is
> a variable and I'm building the ldap string dynamically.
> The tricky part is that the value for
> msExchHideFromAddressLists might be equal to false or it
> might not exist.

 
 
 

Retrieving only non-hidden users

Post by Jim » Wed, 09 Jul 2003 04:56:06


Thanks, this seems to work.  Is the TRUE keyword case
sensitive in this query?  Because with the exception of
case, this is identical to a query that I had tried
previously.
 
 
 

Retrieving only non-hidden users

Post by MVP - ADS » Wed, 09 Jul 2003 05:08:54


Not sure.  The documentation in the AD reference has it all caps, so that's
what I've always used.  Must be if the other way didn't work!  Here is the
reference for the fancy syntax stuff if it helps:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netd...

Joe K.


Quote:> Thanks, this seems to work.  Is the TRUE keyword case
> sensitive in this query?  Because with the exception of
> case, this is identical to a query that I had tried
> previously.

 
 
 

1. Error in retrieving non-standard user properties thru ADSI

Hi,
I have been working on this issue for more than a week now
but all turns out to be unfruitful. Whenever I query AD
for certain non-standard user
properties, "employeeID", "localeID", "primaryTelexNumber",
 "department", and "extensionName", it always returns "The
Active Directory datatype cannot be converted to/from a
native DS datatype" error. I have already looked thru the
MS KB article Q241981 but the solutions don't work!

I appreciate anyone from Microsoft to respond to this
message as I know there are a lot of ADSI developers
facing the same problem as I do. One observation I found
out is that W2K Professional IIS 5.0 does not have any
issue retrieving the properties but all my web servers
with IIS 5.0 do!!

Following is a test code segment.
===
<%
On Error Resume Next
Dim intCount
Dim objConn
Dim objCommand
Dim objRS
Dim objUser

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
Set objCommand = Server.CreateObject("ADODB.Command")
objConn.Open
Set objCommand.ActiveConnection = objConn
objCommand.CommandText = "<LDAP://DC=MYDOMAIN,DC=COM>;
(cn=MyID);ADsPath"
Set objRS = objCommand.Execute

If Not objRS.EOF Then
  Set objUser = GetObject(objRS.Fields("ADsPath")
  objUser.GetInfo
  Response.Write "Employee: " & objUseremployeeID & "<BR>"
  Response.Write "LocaleID: " & objUser.localeID & "<BR>"
  Response.Write "Telex No.: " &
objUser.primaryTelexNumber & "<BR>"
  Response.Write "Department: " & objUser.department
& "<BR>"
  Response.Write "Extension: " & objUser.extensionName
& "<BR>"
End If

Set objUser = Nothing
Set objRS = Nothing
Set objCommand = Nothing
Set objConn = Nothing
%>

2. Help with psfrag

3. Hiding non accessible folders

4. Error when starting Windows 2000

5. ntsecuritydescriptor attribute and retrieving it as non-administrator

6. JBots: Muic not playing in Netscape

7. How can I hide files (non-dot-files)

8. CFP ICCC95

9. How to retrieve non-published documents ?

10. Hiding toolbars from non-authors??

11. Hide some Users from some other users

12. List all users in a domain and retrieve a user password

13. User level access on Win9x - Cannot retrieve list of users