[THIN] Re: Auditing User Logons

  • From: "Magnus" <magnus@xxxxxxxx>
  • To: <thin@xxxxxxxxxxxxx>
  • Date: Mon, 17 Mar 2003 14:07:03 -0500

Just so everyone knows this is done in WSH.  There are 2 scripts that you
need login.vbs and logoff.vbs  they are basically the same with the
exception of what is written to the file.

Use the local Computer policy to define the logon and logoff scipts for the
server
(Local computer policy -> User Configuration -> Windows Settings -> Scripts
(Logon/Logoff)

magnus

****************************************************************************
**********************************************
Login.vbs

Set WSHNetwork = WScript.CreateObject("WScript.Network")

' Get Current Users Username and ComputerName
set shell = WScript.CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings("%USERNAME%")
clientmachine = shell.ExpandEnvironmentStrings("%CLIENTNAME%")
sessionname = shell.ExpandEnvironmentStrings("%SESSIONNAME%")
server = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
TokenFile = "P:\userlog\" & username & ".log"

Const forReading = 1
Const ForWriting = 2
Const ForAppending = 8

CRLF = CHR(10) & CHR(13)

set fs = CreateObject("Scripting.FilesystemObject")

' Check for Token file
if (fs.FileExists(TokenFile)) Then
     
' Create the token file and write information
     set f = fs.OpenTextFile (TokenFile, ForAppending, True)
     f.WriteLine  "Login: " & username & "," & clientmachine & "," &
sessionname & "," & server & "," & Date & " " & Time
     f.Close

Else 
        fs.CreateTextFile(TokenFile)
        ' Create the token file and write information
     set f = fs.OpenTextFile (TokenFile, ForAppending, True)
     f.WriteLine "Log In "
     f.WriteLine username
     f.WriteLine clientmachine
     f.WriteLine sessionname
     f.WriteLine server
     f.WriteLine Date & " " & Time
     f.Close
     set ws=Wscript.CreateObject("Wscript.Shell")

end if

****************************************************************************
*************************************


Logoff.vbs


Set WSHNetwork = WScript.CreateObject("WScript.Network")

' Get Current Users Username and ComputerName
set shell = WScript.CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings("%USERNAME%")
clientmachine = shell.ExpandEnvironmentStrings("%CLIENTNAME%")
sessionname = shell.ExpandEnvironmentStrings("%SESSIONNAME%")
server = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
TokenFile = "P:\userlog\" & username & ".log"

Const forReading = 1
Const ForWriting = 2
Const ForAppending = 8

CRLF = CHR(10) & CHR(13)

set fs = CreateObject("Scripting.FilesystemObject")

' Check for Token file
if (fs.FileExists(TokenFile)) Then
     
' Create the token file and write information
     set f = fs.OpenTextFile (TokenFile, ForAppending, True)
     f.WriteLine  "Logoff: " & username & "," & clientmachine & "," &
sessionname & "," & server & "," & Date & " " & Time
     f.Close

Else 
        fs.CreateTextFile(TokenFile)
        ' Create the token file and write information
     set f = fs.OpenTextFile (TokenFile, ForAppending, True)
     f.WriteLine "Log off "
     f.WriteLine username
     f.WriteLine clientmachine
     f.WriteLine sessionname
     f.WriteLine server
     f.WriteLine Date & " " & Time
     f.Close
     set ws=Wscript.CreateObject("Wscript.Shell")

end if

****************************************************************************
******************************************

-----Original Message-----
From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf
Of Christine Easton
Sent: Monday, March 17, 2003 12:16 PM
To: 'thin@xxxxxxxxxxxxx'
Subject: [THIN] Re: Auditing User Logons


Me too, please.

-Christine


Christine N. Easton
Citrix/Windows 2000 Engineer
Boston Medical Center HealthNet Plan
1 Design Center Place
Boston, MA  02210
Work: 617-414-6034
Cell:  617-293-4407
christine.easton@xxxxxxxxx


-----Original Message-----
From: Brady Pocock [mailto:bpocock@xxxxxxxxxxxxxx]
Sent: Monday, March 17, 2003 12:13 PM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Auditing User Logons



I would be interested in that to if you don't mind.

Thanks

Brady

-----Original Message-----
From: Turman, David C. [mailto:david_turman@xxxxxxxxxxxxxxxx]=20
Sent: Monday, March 17, 2003 11:44 AM
To: 'thin@xxxxxxxxxxxxx'
Subject: [THIN] Re: Auditing User Logons



        Sure. Shoot it to me!

-----Original Message-----
From: Magnus [mailto:magnus@xxxxxxxx]=20
Sent: Monday, March 17, 2003 10:38 AM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Auditing User Logons



How about running a local policy login and log off script that writes the
info to a text file on the local machine.  I have a sample of this if you
would like it

Magnus

-----Original Message-----
From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf
Of Turman, David C.
Sent: Monday, March 17, 2003 10:53 AM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Auditing User Logons




        Anyone know of a good way to audit when a particular user
        logs on and off? The Win2K/ Active Directory auditing tool
        is just too much info. I just want 1 person logging on to
        the domain...

*********************************************************
This Week's Sponsor - RTO Software / TScale
TScale increases terminal server capacity.=20
Get 30-40% more users per server to save $$$ and time.=20
Add users now! - not more servers. If you're using Citrix,=20 you must learn
about TScale!  Free 30-day eval: http://www.rtosoft.com/Enter.asp?ID=3D79
**********************************************************

For Archives, to Unsubscribe, Subscribe or=20
set Digest or Vacation mode use the below link:
http://thethin.net/citrixlist.cfm

*********************************************************
This Week's Sponsor - RTO Software / TScale
TScale increases terminal server capacity.=20
Get 30-40% more users per server to save $$$ and time.=20
Add users now! - not more servers. If you're using Citrix,=20 you must learn
about TScale!  Free 30-day eval: http://www.rtosoft.com/Enter.asp?ID=3D79
**********************************************************

For Archives, to Unsubscribe, Subscribe or=20
set Digest or Vacation mode use the below link:
http://thethin.net/citrixlist.cfm

*********************************************************
This Week's Sponsor - RTO Software / TScale
TScale increases terminal server capacity.=20
Get 30-40% more users per server to save $$$ and time.=20
Add users now! - not more servers. If you're using Citrix,=20 you must learn
about TScale!  Free 30-day eval: http://www.rtosoft.com/Enter.asp?ID=3D79
**********************************************************

For Archives, to Unsubscribe, Subscribe or=20
set Digest or Vacation mode use the below link:
http://thethin.net/citrixlist.cfm
*********************************************************
This Week's Sponsor - RTO Software / TScale
TScale increases terminal server capacity. 
Get 30-40% more users per server to save $$$ and time. 
Add users now! - not more servers. If you're using Citrix, 
you must learn about TScale!  Free 30-day eval:
http://www.rtosoft.com/Enter.asp?ID=79
**********************************************************

For Archives, to Unsubscribe, Subscribe or 
set Digest or Vacation mode use the below link:
http://thethin.net/citrixlist.cfm


*********************************************************
This Week's Sponsor - RTO Software / TScale
TScale increases terminal server capacity. 
Get 30-40% more users per server to save $$$ and time. 
Add users now! - not more servers. If you're using Citrix, 
you must learn about TScale!  Free 30-day eval:
http://www.rtosoft.com/Enter.asp?ID=79
**********************************************************

For Archives, to Unsubscribe, Subscribe or 
set Digest or Vacation mode use the below link:
http://thethin.net/citrixlist.cfm

*********************************************************
This Week's Sponsor - RTO Software / TScale
TScale increases terminal server capacity. 
Get 30-40% more users per server to save $$$ and time. 
Add users now! - not more servers. If you're using Citrix, 
you must learn about TScale!  Free 30-day eval:
http://www.rtosoft.com/Enter.asp?ID=79
**********************************************************

For Archives, to Unsubscribe, Subscribe or 
set Digest or Vacation mode use the below link:
http://thethin.net/citrixlist.cfm

Other related posts: