Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reteiving User Info using LDAP. Date Field does not.

Status
Not open for further replies.

cparralesl

Programmer
Jan 27, 2002
118
NI
Hello guys,

Trying to retreive some user information, but I have problems when retreive Date or Boolean fields. If I incluide Date Fields, the query does not return records. Taking off that date field of the command it does returns records.

I've tried to format or convertig the field using functions with no success.

Here is the code. It is importante to mention that this code is as result of surfing and reading from this forum.

Code:
[COLOR=#8F5902]
Dim PCQuery, oRootDSE, strDNC As String
Dim objConnection As ADODB.Connection
Dim objCommand As ADODB.Command
Dim objRecordSet As ADODB.Recordset
Dim objXls, objBok, Ln, Rw

'First get domain information
Set oRootDSE = GetObject("LDAP://rootDSE")
strDNC = oRootDSE.Get("defaultNamingContext")

PCQuery = "SELECT distinguishedName,sAMAccountName,name,company,mail,homeDirectory,mailNickname,proxyAddresses,memberOf,Title,[b][COLOR=#EF2929]PasswordExpirationDate[/color][/b]" & _
            "FROM 'LDAP://OU=Users,OU=Users and Workstations," & strDNC & "' " & _
            "WHERE objectCategory='Person' and objectClass='user'"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = PCQuery
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
     'assign the computer name and distinguished path to variables
     strusername = objRecordSet.Fields("sAMAccountName")
     strComputer = objRecordSet.Fields("name")
     strComputerDN = objRecordSet.Fields("distinguishedName")
     strCompany = objRecordSet.Fields("company")
     strEmail = objRecordSet.Fields("mail")
     strHomeDir = objRecordSet.Fields("homeDirectory")
     strAlias = objRecordSet.Fields("mailNickname")
     strProxy = objRecordSet.Fields("proxyAddresses").Value
     strGroups = objRecordSet.Fields("memberOf").Value
     strTitle = objRecordSet.Fields("Title").Value
     [b][COLOR=#8F5902]strPwdExp[/color][/b] = objRecordSet.Fields("[b][COLOR=#EF2929]PasswordExpirationDate[/color][/b]").Value
    
     MsgBox "Username   : " & strusername & vbCrLf & _
            "Nombres    : " & strComputer & vbCrLf & _
            "Dist. Name : " & strComputerDN & vbCrLf & _
            "Company    : " & strCompany & vbCrLf & _
            "Mail       : " & strEmail & vbCrLf & _
            "Home Dir   : " & strHomeDir & vbCrLf & _
            "Alias      : " & strAlias & vbCrLf & _
            "Emp. Title : " & strTitle & vbCrLf & _
            "Acct  Exp  : " & strAcctExp
            "Clave Exp. : " & [b][COLOR=#8F5902]strPwdExp[/color][/b]

     objRecordSet.MoveNext
Loop
objConnection.Close
[/color]

Help will be appreciated
Thanks in advance

Cesar Humberto Parrales
Application Support
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top