I'm querying AD through SQL Server using a linked server as described on the
Microsoft site. All is working well, except that I can't query group
descriptions. E.g. the following query works perfectly:
objectClass = ''Group''
According to this site: http://www.dx21.com/scripting/adsi/ADGUI/SG1.ASP
(extremely useful reference, BTW), the ADSI property for the Description
field is 'description'. However, when I add that to the above query, I get
the following error:
Could not get the data of the row from the OLE DB provider 'ADSDSOObject'.
Could not convert the data value due to reasons other than sign mismatch or
OLE DB error trace [OLE/DB Provider 'ADSDSOObject' IRowset::GetData returned
0x40eda: Data status returned from the provider: [COLUMN_NAME=cn
I've done a Google search on that, but can't find anything helpful.
Any assistance gratefully received.
Although description is treated as a single valued attribute by the system,
and you can only assign one value, it is actually a multi-valued attribute,
similar to memberOf. The value returned by ADO can be Null or a Variant()
array with upper bound 0.
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
> Although description is treated as a single valued attribute by the
> system, and you can only assign one value, it is actually a multi-valued
> attribute, similar to memberOf. The value returned by ADO can be Null or a
> Variant() array with upper bound 0.
So how do I do it, then...?
I'm sorry, I don't know what language/environment you are in. I have not
seen how you retrieve description. If VB or VBScript:
adoRecordset.Source = "SELECT distinguishedName, description " _
& "FROM 'LDAP://dc=MyDomain,dc=com' " _
& "WHERE objectCategory = 'person'"
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("distinguishedName").Value
arrDescr = adoRecordset.Fields("description").Value
If IsNull(arrDescr) Then
strDescr = "<none>"
For Each strLine In arrDescr
strDescr = strLine
Wscript.Echo strDN & ";" & strDescr
If you are using T-SQL, I have not seen how to handle this. You would have
the same issue with any multi-valued attribute, like memberOf, objectClass,
otherTelephone, etc. Searching previous newsgroup postings I fear it cannot
be done in T-SQL. There seems to be no datatype that supports multi-valued
fields, even though it seems to be in the recordset. Does anyone else have a
solution in SQL?
> I'm sorry, I don't know what language/environment you are in.
> I have not seen how you retrieve description.
See my original post.