SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Querying ADSI


Querying ADSI

Author
Message
daw21
daw21
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 441

I am having trouble querying one particular active directory attribute, managedObjects. The error message that I'm getting is:

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.

The query runs fine if that field is NULL. I found a kb article on Microsoft's site stating that it is an issue, but we have a later version of the file listed (activeds.dll). The cause listed is as follows:

The ADSI OLE DB provider represents I8 fields by using a DBTYPE_VARIANT(IDispatch) data type and does not convert the I8 data type to a string. SQL Server requires the provider to convert a VARIANT data type to a WSTR data type.

I've tried converting the field to nvarchar, nchar, text and none of them works. Here's my query:

SELECT Manager, Name, sAMAccountName, userPrincipalName, convert(nvarchar, ManagedObjects)

FROM OPENQUERY(ADSI,

'SELECT Name, Manager, sAMAccountName, userPrincipalName, DisplayName, ManagedObjects

FROM ''LDAP://OU=xxxx,DC=xxxx,DC=com''

WHERE objectCategory = ''User''

ORDER BY Name')

Does it need to be converted within the openquery statement, or is there something else that I can try?

Thanks!


Site Owners
Site Owners
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: Administrators
Points: 12709 Visits: 22
No one has responded to this topic yet. Even if you don't have a complete answer, the original poster will appreciate any thoughts you have!
sbajpai
sbajpai
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 11
I am having a similar issue. If I run the following query in SQL 2005 it runs fine but gives an error in SQL 2008.

SELECT *
FROM OPENQUERY(ADSI, 'SELECT sAMAccountName, ipPhone, department,
displayName, homePhone, mail, mobile, company,
sn, l, telephoneNumber, givenName, title,
physicalDeliveryOfficeName
FROM ''LDAP://OU=xxx,DC=xxx,DC=xxx'' WHERE
objectCategory = ''Person'' AND objectClass = ''user'' ')
where company is not null

The error is -
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "ADSDSOObject" for linked server "ADSI".

It seems to error after a certain number of rows (which is different everyday). If I amend the query to include the Top N clause it runs fine. That is not a solution, searching on the internet has yielded no clues.

Any thoughts anyone.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search