Avatar of jamiepryer
jamiepryer
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

objRecordSet.Fields

Hi,

im playing with various scripts, that use an LDAP link to AD to display information on users.

I wanted to know if there is a list somewhere of all the different properties for objectrecordset.fields for users?

for example, in the below example, i wanted to add in the users first name and surname to the code, but im not sure what these fields are called?!
im interested to know what the reference eg ("name") is for all the different fields in AD, so i can use them for different scripts, like telephone number or location etc..etc..
On Error Resume Next
 
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.CommandText = _
    "<LDAP://dc=fabrikam,dc=com>;(&(objectCategory=User)" & _
        "(userAccountControl:1.2.840.113556.1.4.803:=2));Name;Subtree"  
Set objRecordSet = objCommand.Execute
 
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

Open in new window

VB Script

Avatar of undefined
Last Comment
jamiepryer

8/22/2022 - Mon