?
Solved

SQL2005 query into AD via LDAP

Posted on 2010-11-22
3
Medium Priority
?
830 Views
Last Modified: 2012-05-10
Hi

I am querying AD via SQL 2005 but really want to get the description field out of AD but the description field seems to be a reserved word or something in the OLE DB connection as throws an error of "Msg 7346, Level 16, State 2, Line 1 Cannot get the data of the row from the OLE DB provider "ADsDSOObject" for linked server "ADSI". Could not convert the data value due to reasons other than sign mismatch or overflow."

I can retrieve any other field other than the description one

Here is a copy of the query

SELECT * FROM OPENQUERY
      (ADSI,'SELECT description FROM ''LDAP://########'' WHERE objectCategory = ''Computer'' ')

yet this works
SELECT * FROM OPENQUERY
      (ADSI,'SELECT location, physicalDeliveryOfficeName, department, displayName, SN,  
            givenName, sAMAccountName, manager, mail, telephoneNumber, mobile  
            FROM ''LDAP://########WHERE objectCategory = ''Computer'' ')

The AD server is setup as a linked server
0
Comment
Question by:techmiss
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Sander Stad
ID: 34187213
Could you try to put "[" and "]" around the field like this:

SELECT * FROM OPENQUERY
      (ADSI,'SELECT [description] FROM ''LDAP://########'' WHERE objectCategory = ''Computer'' ')
0
 

Accepted Solution

by:
techmiss earned 0 total points
ID: 34187307
I have tried all the usual field validators i.e. [, ' and " but none seem to make any difference.

I am not 100% sure that it is a reserved word but maybe its just a strange data type so I have even tried SELECT * FROM OPENQUERY
      (ADSI,'SELECT CAST(description as varchar(50)) FROM ''LDAP://########'' WHERE objectCategory = ''Computer'' ')

But dont think the OLE DB driver can handle data converting requests.

Thanks for your reply tho as any suggestions are welcome
0
 

Author Closing Comment

by:techmiss
ID: 34399285
Not really answered but found solution elsewhere :-(
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question