Friday, March 9, 2012

Linked Server and ADSI

Does anyone one know how to create a linked server to active directory
on a sql server that is not a domain controller?
I have tried the following to add the linked server
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5',
'ADSDSOObject',
'adsdatasource'
but I can not issue any querys without getting the following error
Server: Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing a query for execution against OLE DB
provider 'ADSDSOObject'.
OLE DB error trace [OLE/DB Provider 'ADSDSOObject'
ICommandPrepare::Prepare returned 0x80040e14].
This is running on a Windows 2000 sql 2000 box.
Thanks in advance.That's fine but you'll need some remote login credentials with which to
query AD (otherwise what security context is it going to use?). I've set up
links to AD from my SQL servers by adding the linked server (as you've done)
and then adding a remote login mapping so that all local logins use a
specific set of credentials to connect via ADSI (I'm not overly concerned
about oppressive security in this case because any user that connects to my
SQL box can also query AD anyway - this just makes multi-source queries a
little more transparent/seamless). Specifically I've set up the mapping so
that all local logins use the service account under which SQL is running
(ie. Windows account). That is,
exec sp_addlinkedsrvlogin 'ADSI', false, NULL,
'MyDomain\MySQLServiceAccount', 'MyServiceAccountPassword'
So any SQL client session that issues an ADSI query through that linked
server will query AD using the service account that SQL server is running
under (this assumes you're running your SQL server under a domain account,
not as System or a local SAM account). Works pretty well for me - the only
thing you have to bear in mind is you can only query the bits of AD that the
SQL service account has been granted permissions to query.
Cheers,
Mike
"sfibich" <sfibich@.pfgc.com> wrote in message
news:u2w7zDOzEHA.1264@.TK2MSFTNGP12.phx.gbl...
> Does anyone one know how to create a linked server to active directory on
> a sql server that is not a domain controller?
> I have tried the following to add the linked server
> EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5',
> 'ADSDSOObject',
> 'adsdatasource'
>
> but I can not issue any querys without getting the following error
> Server: Msg 7321, Level 16, State 2, Line 1
> An error occurred while preparing a query for execution against OLE DB
> provider 'ADSDSOObject'.
> OLE DB error trace [OLE/DB Provider 'ADSDSOObject'
> ICommandPrepare::Prepare returned 0x80040e14].
>
> This is running on a Windows 2000 sql 2000 box.
> Thanks in advance.|||Mike Hodgson wrote:
> That's fine but you'll need some remote login credentials with which to
> query AD (otherwise what security context is it going to use?). I've set
up
> links to AD from my SQL servers by adding the linked server (as you've don
e)
> and then adding a remote login mapping so that all local logins use a
> specific set of credentials to connect via ADSI (I'm not overly concerned
> about oppressive security in this case because any user that connects to m
y
> SQL box can also query AD anyway - this just makes multi-source queries a
> little more transparent/seamless). Specifically I've set up the mapping s
o
> that all local logins use the service account under which SQL is running
> (ie. Windows account). That is,
> exec sp_addlinkedsrvlogin 'ADSI', false, NULL,
> 'MyDomain\MySQLServiceAccount', 'MyServiceAccountPassword'
> So any SQL client session that issues an ADSI query through that linked
> server will query AD using the service account that SQL server is running
> under (this assumes you're running your SQL server under a domain account,
> not as System or a local SAM account). Works pretty well for me - the onl
y
> thing you have to bear in mind is you can only query the bits of AD that t
he
> SQL service account has been granted permissions to query.
>
Thanks that does it.|||I'm hoping you are still checking this newsgroup.
I'm experiencing the same problem and I am using a domain account to start
the services as well as in the security context of the linked server but I
still am having problems executing a query.
Server: Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing a query for execution against OLE DB
provider 'ADSDSOObject'.
It is a Windows 2000 Server OS, SQL Server 2000. The AD is 2003 Server. Any
ideas?
"sfibich" wrote:

> Mike Hodgson wrote:
> Thanks that does it.
>

No comments:

Post a Comment