In our test lab AD, we have three computers, two of them show "Machine Role" in the AD Find box as "Workstation or Server" and the other has role "Domain Controller". I wanted to extract this information into VB, but when I query machineRole it returns nothing in that field.
Heres the script
SET con = CreateObject("ADODB.Connection")
.Provider = "ADsDSOObject"
.Properties("User ID") = "RESTRICTED\Administrator"
.Properties("Password") = inputbox("enter admin pwd")
.Properties("Encrypt Password") = True
.Open "ADs Provider"
Set adoRecordset = CreateObject("ADODB.Recordset")
SQLText = " select Name, canonicalName, distinguishedName, operatingSystem, operatingSystemVersion, OperatingSystemServicePack, OperatingSystemHotfix, dnsHostName, Location, Description, UserAccountControl, whenCreated, whenChanged, machineRole, userAccountControl"
SQLText = SQLText & " FROM 'LDAP://SERVERNAME/DC=RESTRICTED,DC=MYDOMAIN,DC=NET' "
SQLText = SQLText & " WHERE objectClass='Computer' "
adoRecordset.Open SQLText, con
Now adoRecordset.Fields("machineRole").value returns null. I wondered if it was an array so I ran it with cscript using .net 2005 debugger and although it may be an array it has no elements. I have checked this on every record.
Is there a different way of retrieving machineRole - or is it another field ?