OK, I surrender. I'm working on scripting some data from Active Directory and I've hit a bug I just can't figure out. My script is;
'On Error Resume Next
Option Explicit
dim objConnection
dim objCommand
dim objRecordset
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.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name, description, distinguishedName, member FROM 'LDAP://ou=mybusiness,dc=huntfamily,dc=local' WHERE objectCategory='group'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name").Value ' & "," & _
Wscript.Echo objRecordSet.Fields("description").Value
Wscript.Echo objRecordSet.Fields("distinguishedName").Value
Wscript.Echo objRecordSet.Fields("member").Value
objRecordSet.MoveNext
Loop
I"m getting an error of C:\Bin\SecurityGroupt.vbs(26, 2) Microsoft VBScript runtime error: Type mismatch
This is on the line;
Wscript.Echo objRecordSet.Fields("description").Value
Using Active Directory Explorer from Sysinternals, I see the value called description and it says it is a DirectoryString. Anything that I try to do with that value, treating it as a string, gives this error. I tried casting it to a string and got the same thing.
There must be something I am missing. Any suggestions?
WScript.Echo TypeName(objRecordSet.Fields("description").Value)? - Ansgar Wiechers