Solved

Record user logon and off date and times into a database

Posted on 2009-04-07
4
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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