Counter of Festivals

Ashok Blog for SQL Learners and Beginners and Experts

Monday 10 February 2020

Msg 7321, Level 16, State 2, Line 68 An error occurred while preparing the query

Msg 7321, Level 16, State 2, Line 68
An error occurred while preparing the query "

Solution:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/083229e7-58f2-44cf-ae5d-c9acf366818c/sql-2005-ldap-query-error-msg-7321-level-16?forum=transactsql

It normally succeedes test connection generally but when you run query using this linked server to pull data from AD(Active Directory) server it will throw above issue. so issue will be between db server of linked server and AD server.

we need to make sure logins should be same on both AD server and db server
of linked server created.

LDAP means Lightweight Directory Access Protocol


First execute your query:

EXEC sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces',

'ADSDSOObject'

, 'adsdatasource'

GO

Like daw21 explain before follow the detail steps:

Second step go to the SqlServer management Studio and edit manually the Linkserver name ADSI:

go to Server Objects/Linked Servers/  and right click on ADSI  select the option Properties and then go to Security.

Select the option :         Be made using this security context:

and there fill the user  and Password about the valid user with permission into Active Directory, not forget before the domain\user.



(or)

First you have to make sure that Ad Hoc Distributed Queries is enabled ...

sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure
Second you have to make sure that you specify a security context that has access to AD INCLUDING the DOMAIN
Third you should put a row limit (e.g. SELECT TOP 100) in to avoid the issue where you hit the 1000 row limit so
SELECT



TOP 100 *

FROM



OpenQuery(ADSI, 'SELECT sAMAccountName FROM ''LDAP://DC=core,DC=acllab,DC=net'' WHERE objectCategory=''user'' ')

1 comment:

  1. Do you understand there is a 12 word sentence you can communicate to your man... that will induce intense feelings of love and impulsive attraction for you deep within his heart?

    That's because deep inside these 12 words is a "secret signal" that fuels a man's impulse to love, idolize and care for you with all his heart...

    12 Words That Fuel A Man's Love Instinct

    This impulse is so hardwired into a man's genetics that it will make him work harder than ever before to do his best at looking after your relationship.

    Matter of fact, triggering this mighty impulse is absolutely important to achieving the best possible relationship with your man that the instance you send your man one of the "Secret Signals"...

    ...You'll soon notice him open his heart and soul for you in a way he's never expressed before and he'll identify you as the one and only woman in the universe who has ever truly understood him.

    ReplyDelete