Question

Locked

How do I format the query for an array for description field?

By oskiller ·
After some searching, I found out that the reason I am receiving a type mismatch on the description field is that it is an array, but for the life of me I cannot figure out the formatting to make this work:

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location, Description from 'LDAP:// *redacted* ' Where objectClass='computer'"
objCommand.Properties("Page Size") = 1500
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
Wscript.Echo "Description: " & objRecordSet.Fields("Description").Value
objRecordSet.MoveNext
Loop


It finds the first computer fine because the Description field is blank, but chokes on a type mismatch on the next system.

Basically, I'm trying to return the Name, Location and Description field for every computer to see where there are blanks, mismatches etc. I've found plenty of things that state the description field is an array and show various things, but I have not been able to make it work - either I'm inserting it in the wrong place or I have it incorrect.

This seems to be the most common thing I am finding:

arrDesc = objRecordSet.Fields("description").value
If IsNull(arrDesc) Then
strDesc = ""
Else
For Each strLine In arrDesc
'strDesc = strGroupName & " | " & strLine
strDesc = strline
Next
End If


I'm pulling my hair out on this one.

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Web Development Forum
0 total posts (Page 1 of 1)  

Related Forums