+ Post New Thread
Page 1 of 4 1234 LastLast
Results 1 to 15 of 48
Scripts Thread, Script to track user logins in Coding and Web Development; I'm looking for a script that will track the following info to a text or DB file when users login ...
  1. #1

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,659
    Thank Post
    858
    Thanked 646 Times in 429 Posts
    Rep Power
    498

    Script to track user logins

    I'm looking for a script that will track the following info to a text or DB file when users login and again when they logout:

    Date & Time
    Username
    Event (Login / Logoff)
    PC Name
    IP Address

    Anyone able to help me out on this?

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,406
    Thank Post
    639
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    324

    Re: Script to track user logins


  3. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,002
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108

    Re: Script to track user logins

    Quote Originally Posted by webman
    Beat me to it :? You can also modify some of the scipts in this post for a flat file.

  4. #4

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,659
    Thank Post
    858
    Thanked 646 Times in 429 Posts
    Rep Power
    498

    Re: Script to track user logins

    Excellent - thanks guys
    I did search but obviously not that well!!

  5. #5

    Join Date
    Oct 2005
    Location
    East Midlands
    Posts
    738
    Thank Post
    17
    Thanked 105 Times in 65 Posts
    Rep Power
    37

    Re: Script to track user logins

    Hi Guys,

    Here's few scripts that were posted in the communities forum (RM). They have a logon and logoff script which basically records the user's logon and logoff information.

    You need to modify the location of the access database and have i believ write permission on the db.

    There is a help file (PDF) which tells you how to use and set it up. I found it it to be really useful and very easy to setup.


    Ashok.
    Attached Files Attached Files

  6. 2 Thanks to spc-rocket:

    Vinayak (1st July 2013), zag (9th July 2013)

  7. #6

    Join Date
    Oct 2006
    Location
    uk
    Posts
    494
    Thank Post
    19
    Thanked 3 Times in 2 Posts
    Rep Power
    17

    Re: Script to track user logins

    has any one done any work on the database on this i want to interegate it will tell me what machine a user is at . i can do it by searching but its a bit long winded, (hark at me that knows nothing about access at all!) this is a really good app by the way.
    thanks in advance

  8. #7
    StewartKnight's Avatar
    Join Date
    Jun 2005
    Posts
    1,587
    Thank Post
    2
    Thanked 27 Times in 21 Posts
    Rep Power
    30

    Re: Script to track user logins

    you don't need a script, Server logs in 2003 can be made to collect that information

  9. #8

    Join Date
    Oct 2006
    Location
    uk
    Posts
    494
    Thank Post
    19
    Thanked 3 Times in 2 Posts
    Rep Power
    17

    Re: Script to track user logins

    spill the beans then mate stewart ....

  10. #9

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to track user logins

    The problem with these solutions is that they involve scripts running in the security context of the user.

    This is means that a student could find the log/semaphore file and just delete it

    @Stewart
    Yes apart from the IP address, the server security log records all the items Gatt has requested. The problem is that it only does if for access to that server which may be fine use only one DC or only one file server. if you have DFS and DC load balancing in place then you have to search across all you servers to build up a complete record.

  11. #10

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

    Re: Script to track user logins

    Make a dir on the local pc called c:\logs [ you can edit this script to do so if you wish ] Compile the script and run it at logon. It will show this in the txt file and will add a new line everytime a user logs on:

    On 2007-01-24 18:30:30 : User: MattX Logged On To PC: MATTDELL, IP Address: 192.168.1.102


    AutoIT script:

    ; AutoIt Version: 3.10
    ; Language: English
    ; Platform: WinXP
    ; Author: Matt Marsh
    ; Script Function: Script that records logon details in log file
    ; Date: Oct 2005


    Dim $sLogPath = "c:\logs\logger.txt"
    Dim $sLogMsg = "User: "
    _FileWriteLog($sLogPath, $sLogMsg)

    Func _FileWriteLog($sLogPath, $sLogMsg)

    Local $sDateNow
    Local $sTimeNow
    Local $sMsg
    Local $hOpenFile
    Local $hWriteFile
    Local $user
    Local $cname
    Local $ip

    $sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY
    $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC
    $user = @UserName
    $cname = @ComputerName
    $ip = @IPAddress1

    $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg & $user & " Logged On To PC: " & $cname & "," & " IP Address: " & $ip

    $hOpenFile = FileOpen($sLogPath, 1)

    If $hOpenFile = -1 Then
    SetError(1)
    Return 0
    EndIf

    $hWriteFile = FileWriteLine($hOpenFile, $sMsg)

    If $hWriteFile = -1 Then
    SetError(2)
    Return 0
    EndIf

    FileClose($hOpenFile)
    Return 1
    EndFunc

  12. Thanks to mattx from:

    ICT_GUY (20th November 2009)

  13. #11

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to track user logins

    Huge problem Matt. The logs would be stored on each PC. There's still the problem of the script/EXE running in the student security context.

    What is need is an RPC based client/server solution (did I get the words right Geoff? )

  14. #12

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740

    Re: Script to track user logins

    Why is it a huge problem ? Just re-direct the TXT file to a share or the users profile.
    Control the EXE with a policy if you are worried about security...
    RPC based client / server solution ? OVERKILL for such a simple task. Why make this complex when it does not have to be.
    Keep it simple - always been my motto. The script is not there to be used as is, it may offer a solution or a work around which they can adjust to their own requirements. Each network / school is different - I only posted it as a solution to how I log things on our network.

  15. #13


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Script to track user logins

    alternate:
    install a syslog client on your DC's and have them send the eventvwr message to a centralised mysql database. Search the database with phpsyslogng

    http://www.phpwizardry.com/php-syslog-ng.php

  16. #14

    Join Date
    Oct 2006
    Location
    uk
    Posts
    494
    Thank Post
    19
    Thanked 3 Times in 2 Posts
    Rep Power
    17

    Re: Script to track user logins

    whoah hang on did i miss something??rpc?security contexts? the logon recorder scripts and database provided work very well (fantastically well even) my problem is that i want to query the database so that i can ask it who is sat at what machine at any given time but i don't do access any body out there done anything with this?

  17. #15


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Script to track user logins

    Clearly it can be done securely
    My suggestion was to redirect (ssl) the windows eventvwr logs to another (secured database) server so it can be easily searched through an (ssl enabled) browser (with a password) - this way if your DC gets rooted or dies - you still get to see the last event - arguably more secure, and centralised for easy searching by admin. why not do it to all servers - you get print stats and all sorts in one place.

    http://www.intersectalliance.com/projects/index.html

SHARE:
+ Post New Thread
Page 1 of 4 1234 LastLast

Similar Threads

  1. Make a script run for SINGLE domain user
    By philtomo-25 in forum How do you do....it?
    Replies: 5
    Last Post: 15th November 2007, 09:21 PM
  2. Concurrent user logins on 2k3 domain
    By doco in forum Windows
    Replies: 4
    Last Post: 26th June 2007, 11:33 AM
  3. Track user logons?
    By Jon1 in forum Windows
    Replies: 33
    Last Post: 22nd June 2007, 02:44 PM
  4. Script to change user email in AD (or Exchange)
    By SpuffMonkey in forum Scripts
    Replies: 16
    Last Post: 8th November 2005, 10:31 PM
  5. Script to create a local user on a XP box.
    By tosca925 in forum Scripts
    Replies: 3
    Last Post: 12th October 2005, 12:04 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •