Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distributed Query Not Returning Any Results

Status
Not open for further replies.

glewis1636

Programmer
Apr 26, 2004
39
US
I'm trying to get my users' e-mail addresses from active directory. after much distress and head pounding, I finally (at least apparently) have successfully created a linked server to my active directory. The problem is that I am getting no results from my query on users. Here is my code...

Code:
CREATE VIEW viewADContacts
AS
SELECT  [Name], sn [Last Name], street [Street], l [City], st [State], mail [E-mail]
FROM OPENQUERY( ADSI, 
     'SELECT name, sn, street, l, st, mail
      FROM ''LDAP://stexxxx/DC=soidom001,DC=local''
      WHERE objectcategory = ''person'' and
      objectClass = ''user''')
GO
SELECT * FROM viewADContacts

I'm 95% certain of the LDAP statement based on looking at the active directory. Any ideas on what else could cause me to get no results?

Thanks
 
I don't know anything about active directory, but i know a little about SQL.

Either there are no records, or you're filtering them out. To check, eliminate the "WHERE" clause completely.
 
try

Code:
CREATE VIEW viewADContacts
AS
SELECT  [Name],
	[sn] AS [Last Name],
	[street] AS [Street],
	[l] AS [City],
	[st] AS [State],
	[mail] AS [E-mail]
FROM OPENQUERY( ADSI,
     'SELECT name, sn, street, l, st, mail
      FROM ''LDAP://stexxxx/DC=soidom001,DC=local''')
GO
SELECT * FROM viewADContacts
 
I'm trying to get e-mail addresses from the users in Active Directory. I know that the object class of the users is 'user'. I had tried the query without adding the objectcategory to the where statement, and got the same results.
I also know that the active directory has records.

I guess it's back to the 5% doubt I have about the LDAP portion of my statement...

Thanks anyway, Luzian.
 
I got it!
The problem was with my login credentials... Once I got that sorted out, I got my results!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top