Monday, 19 March 2012

Connect SQL with Active Directory

Hi everybody. I have this problem: I have to access to the Active Directory of a remote server from my computer using SQL and make searches based on the LDAP of the server. Someone told me to use Add Linked Server, but I don't know how to do it with the Active Directory. Thanks for the help.

Please take a look at the link below for the solution:

http://msdn2.microsoft.com/en-US/library/ms190803.aspx

Books Online topics on linked servers are also useful to know. Note that there are however restrictions on what you can do via distributed queries. For example, some of the collection data types in the Active Directory Schema are not supported in SQL Server, number of rows that you can retrieve is restricted by default & so on.

|||

Linking SQL Server to Active Directory is tricky. and Microsoft support/help isn't very intuitive for this.
Check a few things first...
1. two single quotes not double.
2. Make connection w/out security context.


Follow this syntax:
EXEC master.dbo.sp_addlinkedserver @.server = N'ADSI',
@.srvproduct=N'Active Directory Services', @.provider=N'ADsDSOObject',
@.datasrc=N'Servername.domain.com' --AKA the full computer name of the AD server

Then execute the openquery like this:

select * from openquery
(
ADSI,'SELECT name
FROM ''LDAP://Servername.domain.com''
WHERE objectCategory = ''Person'' AND objectClass = ''user''
')

I couldn't find anything on the Internet that would help me.

No comments:

Post a Comment