If you need to access some Active Directory information from SQL Server you can use the openquery command with the ADSI provider, below is an example for doing that
from openquery(adsi, '
where objectCategory = ''Person''
objectClass = ''user''
and sAMAccountName = ''useraccountname''
You also must consider the segurity required inside Active Directory to allow the SQL Server Service account access to the corresponding OU, you can do it with Active Directory Users and Computers with Advance Features Enable and choosing the Security menu as show in the following figure:
You must give read access to the SQL Server Service Account.
Ing. Eduardo Castro Martínez, PhD – Microsoft SQL Server MVP
Technorati Tags: SQL Server
LiveJournal Tags: SQL Server
del.icio.us Tags: SQL Server