Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Query AD using a SQL Linked Server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-30 : 09:38:14
Keith writes "Is it possible to query active directory using a SQL Linked Server? We're looking to validate users' email addresses that exist Exchange Server from within a stored procedure."

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-07-30 : 12:00:00
Check out linked server in BOL

Here's an example :

sp_addlinkedserver 'ADSI','Active Directory Services
2.5','ADSDSOObject','adsdatasource'
go


If exists (select 1 from openquery(ADSI, 'select mail from ''LDAP://EXSERVER'' WHERE mail=''JSmith@nospam.co.uk'''))
print 'email valid'
else
print 'email not found'

In this case I am querying one of our Exchange servers (that's not its real name ) via LDAP to match the email address. Similar principal applies to AD - jsut got to learn the odd syntax


HTH
Jasper Smith
Go to Top of Page
   

- Advertisement -