How to get Login & Log-off, name&Timing from VB
hi,
i want to get login name of the user when logged into the system and log-off timing of the particular user.i need help...
waiting for the reply...
shrini :confused:
[196 byte] By [
shrini] at [2007-11-11 7:54:06]

# 1 Re: How to get Login & Log-off, name&Timing from VB
Use the GetUserName API to get the login name.
What do you mean with log-off timing?
Marco
mstraf at 2007-11-11 17:26:16 >

# 2 Re: How to get Login & Log-off, name&Timing from VB
AFAIK there is no support for a last logoff time if that is what you are asking.
# 3 Re: How to get Login & Log-off, name&Timing from VB
Use the GetUserName API to get the login name.
What do you mean with log-off timing?
Marco
Actually i need want to get the username and what time did he logged into the system and what time did he log-off the system.
This is the application i am trying to do in Vb.
Atpresent i used environ function to get the user name but when he user log-off from the system i want to get his name and time when he logoff from the system.
shrini at 2007-11-11 17:28:16 >

# 4 Re: How to get Login & Log-off, name&Timing from VB
You can use ADSI (Project...References...Active DS Type Library) to retrieve the last time a user logged into the domain. However the last logoff time property does not seem to work properly. I'll check to see if there is another way.
Dim objDomain As IADs
Dim objSystemInfo As ADSystemInfo
Dim strDNSDomain As String
Dim objUser As IADsUser
Set objSystemInfo = CreateObject("ADSystemInfo")
strDNSDomain = objSystemInfo.DomainShortName
Set objUser = GetObject("WinNT://" & strDNSDomain & "/" & Environ("username") & ",user")
Debug.Print objUser.LastLogin
# 5 Re: How to get Login & Log-off, name&Timing from VB
From what I can determine it doesn't appear that the LastLogoff time is stored by the domain controller. About the only other way I can think of to retrieve the information is to use WMI and query the Event Log of the users computer. The following may help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting06112002.asp
http://www.eggheadcafe.com/articles/20010614a.asp
http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/monitoring_events.asp
http://www.microsoft.com/technet/scriptcenter/guide/sas_log_udqz.mspx
http://support.microsoft.com/default.aspx?scid=kb;en-us;174074
# 6 Re: How to get Login & Log-off, name&Timing from VB
pls mail me how to log in for data entry job pls