Search code examples
sqlsql-serveractive-directoryadsi

Can't query for description from SQL using ADSI


I have a linked server using ADSI. I can successfully query for most attributes except description.

My query:

SELECT * FROM OpenQuery (ADSI,  
    'SELECT description,sn,givenName
    FROM  ''LDAP://mydomain.com/OU=users,DC=com,DC=mydomain'' 
    WHERE title<>''Virtual'' AND (userAccountControl=''66048'' OR 
    userAccountControl=''512'')') 
ORDER BY sn

It throws this error:

"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."

What is the problem here?


Solution

  • The field description is multivalued.

    See here:

    https://msdn.microsoft.com/en-us/library/ms675492(v=vs.85).aspx

    SQL Server does not support multivalued fields and therefore you won't be able to get that one in your query.