Solved

Record user logon and off date and times into a database

Posted on 2009-04-07
4
517 Views
Last Modified: 2012-05-06
Hi all.

Wondering if the above is posible. and if so how???

We have been using Group Policy to  log all users logon's and logoff's on our network.

This is only recording it into a txt file or csv file.  This really is not helping with a automated preview as the data is inserted differently. i,e, some PC's insert Logoff Username PCName Day Date Time, where as other only put in Logoff Username PCName Date Time (Leaving of the day) which i can nto automate...


I was wondering if there is anyway i can record this information without having to import it into a database.

I was wondering either Access or SQL. I was thinking along the lines of SQLCMD, but as far as i can see, unless i have it installed on every PC, it will not work.

Does any have any suggestions??

Baker
------So far----
rem ------logon.cmd----
echo logon %username% %computername% %date% %time% >> \\postmaster2\log\logon.log
echo logon %username% %computername% %date% %time% >> \\postmaster2\log\log_on.csv
 
rem -----logoff.cmd-----
echo logoff %username% %computername% %date% %time% >> \\postmaster2\log\logoff.log
echo logoff %username% %computername% %date% %time% >> \\postmaster2\log\log_off.csv

Open in new window

0
Comment
Question by:Bakersville
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:brittonv
ID: 24086730
Just to be sure, did you know that there is a built in auditing ability in Windows?
http://technet.microsoft.com/en-us/library/bb742436.aspx 
0
 
LVL 1

Author Comment

by:Bakersville
ID: 24086869
Thank you for that.

My issue is that i have to try and find the amount of time they are spending on their PC, so need to be able to pull this information into somewhere i can automaticlly generate reports.

This is why i was wondering if something like sqlcmd is worth a shot?
0
 
LVL 8

Accepted Solution

by:
brittonv earned 500 total points
ID: 24087224
To be honest I don't know if you can do it with sqlcmd.

Here is a script that shows the last logon.  Perhaps you could use a script that calculates the time logged on and puts that in your text file instead.
'<script language="vbscript">
OPTION EXPLICIT
 
DIM oNet, strComputerName, strUserName, strUserDomain
SET oNet = CreateObject("WScript.Network")
strComputerName = oNet.Computername
strUserName = oNet.UserName
strUserDomain = oNet.UserDomain
'msgbox strUserDomain
SET oNet = nothing
 
 
DIM oUser, strReturn
on error resume next
SET oUser = GetObject("WinNT://" & fnGetWorkgroupName(".") & "/" & strComputerName & "/" & strUserName & ",user")
strReturn = oUser.LastLogin
on error goto 0
SET oUser = nothing
 
IF isDate(strReturn) THEN
	strReturn = cdate(strReturn)
	strReturn = Replace(strReturn, ":" & Right(0 & Second(strReturn), 2) & " ", "")	'drop seconds
END IF
 
 
On Error Resume Next
	call WScript.Echo(strReturn)	'for cmd line
	call Echo(strReturn)	'for BGInfo
on error goto 0
 
 
 
' gets current workgroup
' params: computer name (can take "." for current computer instead)
' returns: string of computer's current workgroup
FUNCTION fnGetWorkgroupName(p_strComputer)
	DIM colItems, oItem
	Set colItems = GetObject("winmgmts:\\" & p_strComputer & "\root\cimv2").ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each oItem in colItems
		fnGetWorkgroupName = oItem.Domain
	Next
	SET colItems = nothing
END FUNCTION

Open in new window

0
 
LVL 1

Author Closing Comment

by:Bakersville
ID: 31567475
Thank you, this pointed me in the right firection
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question