Sunday, March 11, 2012

Can't run LDAP Query From Remote Machine

Hi all,
I have a SQL 2005 server with a linked server which points to our
active directory. I am able to query the active directory from the
local machine when RDC'ed into the server, but when I run the query
from a remote machine using Management Studio, I get this error:
Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "SELECT *
FROM 'LDAP://prudc/DC=<domain>,DC=com'
" against OLE DB provider "ADSDSOObject" for linked server "ADSI".
The query is:
SELECT *
FROM OPENQUERY( ADSI,
'SELECT *
FROM ''LDAP://prudc/DC=<domain>,DC=com''
'
)
(note I replaced our domain name with <domain> in the above query and
error message)
This issue isn't specific to the above query as I've tried many ldap
queries and they have all worked on the local machine but failed on the
remote machine.
I'm completely stomped on this and would greatly appreciate any help I
can get.
Thanks
Hi Jim
This was a previous post when someone had the same error
http://tinyurl.com/pjg7s I am not sure how much use it will be!
If the query works on the server then I would expect it to be ok, which
probably leaves permission/access as the main issue. Can you use VB script to
query the AD e.g. using the scripts from http://www.rlmueller.net/?
John
"Jim" wrote:

> Hi all,
> I have a SQL 2005 server with a linked server which points to our
> active directory. I am able to query the active directory from the
> local machine when RDC'ed into the server, but when I run the query
> from a remote machine using Management Studio, I get this error:
>
> Msg 7320, Level 16, State 2, Line 1
> Cannot execute the query "SELECT *
> FROM 'LDAP://prudc/DC=<domain>,DC=com'
> " against OLE DB provider "ADSDSOObject" for linked server "ADSI".
>
> The query is:
> SELECT *
> FROM OPENQUERY( ADSI,
> 'SELECT *
> FROM ''LDAP://prudc/DC=<domain>,DC=com''
> '
> )
> (note I replaced our domain name with <domain> in the above query and
> error message)
>
> This issue isn't specific to the above query as I've tried many ldap
> queries and they have all worked on the local machine but failed on the
> remote machine.
> I'm completely stomped on this and would greatly appreciate any help I
> can get.
> Thanks
>
|||Thanks for the help but unfortunately, I've already looked at that post
and the issue is a bit different.
The issue I'm having seems to have something to do with running a query
from a remote machine. So if I run a query on our SQL Server box from
my local desktop machine, I get the error. Running the query directly
on the SQL Server box while RDCed into the machine works flawlessly.
I did try to run a .vbs script from my machine which was able to query
the active directory...thanks for the link =). This leads me to
believe that it has something to do with SQL server security
restricting queries run from remote machines. I ran the surface area
configuration utility and didn't really see anything that jumped out at
me...
Anyone have any ideas?
|||Alright, I've figured out a fix..
The AD linked server that I originally created was set to login to AD
with the credentials of the current security context. I changed this
to log in with a specified login and it worked fine. Whats strange is
that I set it to my own login account which I was using to run the
query remotely anyways. I guess SQL server queries ran remotely are
not run under the logged in users' security context after all?
Thanks for your help John =).

No comments:

Post a Comment