Query AD With No Linked Server

Is it possible to pull name & email from Active Directory using SSMS w/o a linked server connection?

And this would be using SQL 2008

August 28th, 2015 8:54am

Hello,

You can use the OPENDATASOURCE (Transact-SQL) function, here you can use a individual connection string.

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 9:04am

Hello,

You can use the OPENDATASOURCE (Transact-SQL) function, here you can use a individual connection s

August 28th, 2015 9:18am

In MSDN you always have the Option to switch to any other available version, so yes, you can use it in SQL Server 2008

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 9:35am

I tried this query

SELECT
*
FROM OPENROWSET('ADSDSOObject', '','SELECT cn, ADsPath FROM ''LDAP://DC=Fabricam,DC=com'' WHERE objectCategory=''group'' AND cn=''D*''')

which presents an error of 

Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT cn, ADsPath FROM 'LDAP://DC=Fabricam,DC=com' WHERE objectCategory='group' AND cn='D*'" for execution against OLE DB provider "ADSDSOObject" for linked server "(null)".

August 28th, 2015 9:51am

Yes, ad hoc queries have been enabled and I have permission to query AD (I am a domain admin)
August 28th, 2015 10:42am

Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT cn, ADsPath FROM 'LDAP://DC=Fabricam,DC=com' WHERE objectCategory='group' AND cn='D*'" for execution against OLE DB provider "ADSDSOObject" for linked server "(null)".

I received a similar issue with the "linked server "(null)"" error with a different provider.  To resolve it, I had to change the provider properties and enable "Allow inprocess".  Depending on your query, you may need to enable "Dynamic parameter" as well.
Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 11:16am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics