Can someone please tell me what I'm doing wrong here? I've been trying to get this (seemingly) simple thing to work, but it seems to be beyond me. I'm trying to write a VB.NET program to get the last logon time for a user. The form has a combo box that is loaded with sites at startup. When a site is selected, a list box gets all the users in that site. When the username is double-clicked, it calls the following code:
Sub CheckLastLogon(ByVal strSite As String, ByVal strUser As String)
Dim strUserDN As String = "LDAP://CN=" & strUser & ",OU=Users,OU=" & strSite & strDomain
Dim deUser As New DirectoryEntry(strUserDN)
Dim pvcLast As PropertyValueCollection = deUser.Properties("lastLogon")
The problem is that I can't for the life of me figure out what to do with the "pvcLast" variable once I've retrieved it. For now, I'd like to just get it to display in a MsgBox so I know that I'm retrieving it correctly; I can do more with it later, once I've gotten it in the first place. Most things I try to do to it either give me a "Type Mismatch" error or, even more helpful (to me, at least) "System.ArgumentException - Argument 'Prompt' cannot be converted to type 'String'." or some such. The VBScript version of doing this seems so easy, why should the VB.NET version be so difficult? Grr.
PS: Yes, I realize that later I'm going to have to modify it so that it'll check all domain controllers. Right now I just want to see that I can get the lastLogon value, and successfully convert it into a valid date/time.