Can anyone help me out with a few Active Directory field names, how to
find them, or what they are? I'm struggeling to find the the names
for;
- the user profile logon script
- the terminal services profile path
- I would also like to return the list of security permissions, and
the list of groups each user is a member of, but I have a feeling,
being a list they will be more complicated to return.
So far what I have works fine for the easy bits ( account name, email
address, NT profile path). I am building a database of User data for
our ID dept, and this part grabs info from AD, I will run this
regularly to update me DB. Here is some of what I have so far,
hopefully that will help you see what I'm doing.
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Use ADO to search Active Directory.
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "Active Directory Request"
Set oCommand.ActiveConnection = oConnection
' gets the DNS domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfig = objRootDSE.Get("configurationNamingContext")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
classFilter = "(&(objectCategory=person)(objectClass=user))"
strType = "user"
strAttributes = "sAMAccountName,objectClass,ADsPath,lastLogon,distinguishedName,userAccountControl"
sQuery = "<LDAP://" & strDNSDomain & ">;" & classFilter & ";" &
strAttributes & ";subtree"
oCommand.CommandText = sQuery
oCommand.Properties("Page Size") = 1000
oCommand.Properties("Timeout") = 60
oCommand.Properties("Cache Results") = False
Set oResults = oCommand.Execute
' Loop through oResults(the AD objects) and print out the results
Do Until oResults.EOF
Set oGroup = GetObject("LDAP://" & strDNSDomain)
Set oUser = GetObject(oResults.Fields("ADsPath"))
' Output results
Set file = oFSO.OpenTextFile(sLogFile, 8, True)
file.Write("SAM account name: " & oUser.SAMAccountName & "; ")
file.Write("E-mail address: " & oUser.Mail & "; ")
file.Writeline("User profile path: " & oUser.ProfilePath & "; ")
oResults.MoveNext
file.Close
Loop
oConnection.Close
At the moment all I think I'm after is the field that I would append
to oUser, eg something like oUser.LogonScript to return the logon
script, however it's not 'LogonScript' and I have tried everything I
can think of. I know there fields exist as I have filled them out in
AD in some cases myself.
Any help would be greatly appreciated.
Thanks