|
|
Question : Active Directory VBScript not returning role correctly
|
|
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") With con .Provider = "ADsDSOObject" .Properties("User ID") = "RESTRICTED\Administrator" .Properties("Password") = inputbox("enter admin pwd") .Properties("Encrypt Password") = True .Open "ADs Provider" End With 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 ?
thanks
|
Answer : Active Directory VBScript not returning role correctly
|
|
I think it is the attribute and not the provider I tried using the adsi .get method and it failed as well
The only uncommon characteristic about it is the syntax is 'enumerate', I would have thought it to be a string
The only tool I use to inspect all AD attributes is the schema snap-in
|
|
|
|
|