SQL Linked Server Query for AD Returns Msg 7321

送分小仙女□ 提交于 2019-12-12 15:58:45

问题


So I have a SQL query that pulls data from our Active Directory without any issues (slimmed way down for posting purposes):

SELECT TOP 901 * 
FROM OpenQuery(ADSI, 'SELECT title, displayName, sAMAccountName, givenName, sn 
               FROM ''LDAP://DC=[STUFF],DC=[MOAR STUFF],DC=com'' 
               where objectCategory = ''Person'' AND objectClass = ''User''')

This pulls records as expected. I need to pull records from other domains where we have a trust, so I should only need to change the LDAP string. But doing so just returns a generic

"An error occurred while preparing the query...for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI"**" (Msg 7321, Level 16, State 2).

I say generic, because I can type just about anything into that SELECT statement (to mess it up), and I'll get the same message.

I've tried with and without the FQDN in the string. I've confirmed the login being used with the linked server has read access. Any ideas?

Thanks in advance!

-Karl


回答1:


So it appears this "Cross Forest SQL Query" doesn't handle external accounts too well - even if the account is granted Domain Admin. The solution was to get a local account on the trusted domain. Using that local account with the linked server did the trick. In my case, I'm using a separate linked server for each domain. I reckon there would be a more elegant solution, but it hasn't occurred to me yet.



来源:https://stackoverflow.com/questions/22920175/sql-linked-server-query-for-ad-returns-msg-7321

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!