johnlopez2000
Programmer
Colleagues,
I have written the following function to extract users data from AD:
which works fine.
However I am trying to get user status information, using some fields I found in LDAP documentation ...
but it would appear that the ADODB provider can not return the above.
I assume then that it is either only available via a subsequent LDAP query or has some alternate attribute names in the AD database. I DO NOT really want to do this as a subsequent LDAP query, but just get it as part of the initial ADOBD query.
Thanks
John
John Lopez
Enterprise PDM Architect
I have written the following function to extract users data from AD:
Code:
function GetUserInformation (UserName)
dim objConnection, objCommand, objRecordSet
CheckUserResult = CheckUser(UserName)
if CheckUserResult = "True" then
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<GC://ou=Landing Gear Division,dc=goodrich,dc=root,dc=local>;" & _
"(&(objectCategory=person)(objectClass=user)" & _
"(sAMAccountName="&UserName&"));" & _
"sAMAccountName, displayName, distinguishedName, givenName, initials, sn, mail, userPrincipalName, streetAddress, l, st, postalCode, c, telephoneNumber, pager, mobile, info, facsimileTelephoneNumber, title, department, company, manager;subtree"
Set objRecordSet = objCommand.Execute
GetUserInformation = "UserName=" & UserName & VBNEWLINE & _
"exists=True" & VBNEWLINE & _
"sAMAccountName=" & objRecordSet.Fields("sAMAccountName").Value & VBNEWLINE & _
"displayName=" & objRecordSet.Fields("displayName").Value & VBNEWLINE & _
"givenName=" & objRecordSet.Fields("givenName").Value & VBNEWLINE & _
"initials=" & objRecordSet.Fields("initials").Value & VBNEWLINE & _
"surname=" & objRecordSet.Fields("sn").Value & VBNEWLINE & _
"userPrincipalName=" & objRecordSet.Fields("userPrincipalName").Value & VBNEWLINE & _
"distinguishedName=" & objRecordSet.Fields("distinguishedName").Value & VBNEWLINE & _
"email=" & objRecordSet.Fields("mail").Value & VBNEWLINE & _
"info=" & objRecordSet.Fields("info").Value & VBNEWLINE & _
"streetAddress=" & objRecordSet.Fields("streetAddress").Value & VBNEWLINE & _
"city=" & objRecordSet.Fields("l").Value & VBNEWLINE & _
"state=" & objRecordSet.Fields("st").Value & VBNEWLINE & _
"postalCode=" & objRecordSet.Fields("postalCode").Value & VBNEWLINE & _
"country=" & objRecordSet.Fields("c").Value & VBNEWLINE & _
"telephoneNumber=" & objRecordSet.Fields("telephoneNumber").Value & VBNEWLINE & _
"pager=" & objRecordSet.Fields("pager").Value & VBNEWLINE & _
"mobile=" & objRecordSet.Fields("mobile").Value & VBNEWLINE & _
"facsimileTelephoneNumber=" & objRecordSet.Fields("facsimileTelephoneNumber").Value & VBNEWLINE & _
"title=" & objRecordSet.Fields("title").Value & VBNEWLINE & _
"department=" & objRecordSet.Fields("department").Value & VBNEWLINE & _
"company=" & objRecordSet.Fields("company").Value & VBNEWLINE & _
"manager=" & objRecordSet.Fields("manager").Value
objConnection.Close
else
GetUserInformation = "UserName=" & UserName & VBNEWLINE & _
"exists=False"
end if
End Function
which works fine.
However I am trying to get user status information, using some fields I found in LDAP documentation ...
Code:
[b]
objRecordSet.Fields([COLOR=red]"AccountDisabled"[/color]).Value
objRecordSet.Fields([COLOR=red]"AccountExpirationDate"[/color]).Value
objRecordSet.Fields([COLOR=red]"IsAccountLocked"[/color]).Value
[/b]
but it would appear that the ADODB provider can not return the above.
I assume then that it is either only available via a subsequent LDAP query or has some alternate attribute names in the AD database. I DO NOT really want to do this as a subsequent LDAP query, but just get it as part of the initial ADOBD query.
Thanks
John
John Lopez
Enterprise PDM Architect