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 1Cannot 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.
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
FROM
'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!