martes, 9 de marzo de 2010

Query Active Directory from SQL Server

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

 

select *

from openquery(adsi, '

select            displayName

from    ''LDAP://dc=comunidadwindows,dc=org''

where   objectCategory = ''Person''

        and

        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:

 

clip_image002

 

You must give read access to the SQL Server Service Account.

 

Regards,

 

Ing. Eduardo Castro Martínez, PhD – Microsoft SQL Server MVP

http://mswindowscr.org

http://comunidadwindows.org

Costa Rica

Technorati Tags: SQL Server

LiveJournal Tags: SQL Server

del.icio.us Tags: SQL Server

http://ecastrom.blogspot.com

http://ecastrom.wordpress.com

http://ecastrom.spaces.live.com

http://universosql.blogspot.com

http://todosobresql.blogspot.com

http://todosobresqlserver.wordpress.com

http://mswindowscr.org/blogs/sql/default.aspx

http://citicr.org/blogs/noticias/default.aspx

http://sqlserverpedia.blogspot.com/




Note: Cross posted from Eduardo Castro.

Permalink

No hay comentarios:

Publicar un comentario