+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
Coding Thread, Script to capture logon details and output in webpage in Coding and Web Development; Hi there I am relatively new to coding/scripting so please bear with me. I want to create a web page ...
  1. #1
    triggmiester's Avatar
    Join Date
    Jan 2007
    Posts
    205
    Thank Post
    14
    Thanked 11 Times in 9 Posts
    Rep Power
    18

    Script to capture logon details and output in webpage

    Hi there

    I am relatively new to coding/scripting so please bear with me.

    I want to create a web page with a seating plan of our IT room, every time a user logons on I want the web page to show who is logged on to what computer. I have tried something along the lines of this;

    % On error resume next
    strComputer = it111
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
    For Each objComputer in colComputer
    Wscript.Echo objComputer.UserName
    Next


    Wscript.Quit
    %

    ...but not had much luck so far. Could anyone help me please??

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227

    Re: Script to capture logon details and output in webpage

    I wouldn't do it this way. I'd replace GINA on the machines with pGINA and use the MySQL Logging plugin to record login/logoff information in a database on the webserver. Then it's just a case of writing some PHP to extract this information and display it how you want as a web page.

  3. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Re: Script to capture logon details and output in webpage

    Surely your not advocating changing the GINA Geoff?????

  4. #4

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227

    Re: Script to capture logon details and output in webpage

    Replacing != Modifying

  5. #5

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,613
    Thank Post
    746
    Thanked 1,706 Times in 1,519 Posts
    Rep Power
    437

    Re: Script to capture logon details and output in webpage

    Indeed using your own gina is fine it's is modifying the MS one that is not allowed.

    Ben

  6. #6
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Whittington, Lancashire
    Posts
    286
    Thank Post
    40
    Thanked 36 Times in 26 Posts
    Rep Power
    26

    Re: Script to capture logon details and output in webpage

    We write logons to a MySQL database using a logon vbscript. We use another vbscript to delete the entries from the database at logoff. If you do this you could run a script to query the database and output the result to a web page?

    To get computer and user information we have this as part of our vbscript:

    Set WshNetwork = Wscript.CreateObject("Wscript.Network")
    strComputer = WshNetwork.ComputerName
    strUser = WshNetwork.UserName

  7. #7

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,806
    Thank Post
    880
    Thanked 684 Times in 453 Posts
    Rep Power
    505

    Re: Script to capture logon details and output in webpage

    Looking for a similar vbScript to write following to a SQL 2005 DB and logon & logoff..

    Computer Name
    IP Address
    Username
    Date & Time

    Got a C# app that will then read the SQL database and allow users to search for the above details..

  8. #8

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,850
    Thank Post
    110
    Thanked 598 Times in 514 Posts
    Blog Entries
    1
    Rep Power
    227

    Re: Script to capture logon details and output in webpage

    The MySQL logger for pGINA will log that information for you.

  9. #9
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Whittington, Lancashire
    Posts
    286
    Thank Post
    40
    Thanked 36 Times in 26 Posts
    Rep Power
    26

    Re: Script to capture logon details and output in webpage

    Quote Originally Posted by Gatt
    Looking for a similar vbScript to write following to a SQL 2005 DB and logon & logoff..

    Computer Name
    IP Address
    Username
    Date & Time

    Got a C# app that will then read the SQL database and allow users to search for the above details..
    Getting the date and time can be done like this:

    Dim strDate
    Dim strTime
    strDate = CStr(Date)
    strTime = CStr(Time)

    You could use WMI to get the IP address. Let me have a quick check...

  10. #10

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,806
    Thank Post
    880
    Thanked 684 Times in 453 Posts
    Rep Power
    505

    Re: Script to capture logon details and output in webpage

    Quote Originally Posted by Geoff
    The MySQL logger for pGINA will log that information for you.
    Umm.. I dare say it can.. if i wanted to log it to a MySQL database... :?

    Quote Originally Posted by altecsole
    Quote Originally Posted by Gatt
    Looking for a similar vbScript to write following to a SQL 2005 DB and logon & logoff..

    Computer Name
    IP Address
    Username
    Date & Time

    Got a C# app that will then read the SQL database and allow users to search for the above details..
    Getting the date and time can be done like this:

    Dim strDate
    Dim strTime
    strDate = CStr(Date)
    strTime = CStr(Time)

    You could use WMI to get the IP address. Let me have a quick check...
    Cheers

  11. #11
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Whittington, Lancashire
    Posts
    286
    Thank Post
    40
    Thanked 36 Times in 26 Posts
    Rep Power
    26

    Re: Script to capture logon details and output in webpage

    Okay. Here's some WMI to get the NIC type, MAC, IP and subnet.
    Attached Files Attached Files

  12. #12

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,081
    Thank Post
    210
    Thanked 431 Times in 311 Posts
    Rep Power
    145

    Re: Script to capture logon details and output in webpage

    Going back to the origenal question, I've got a bit of a 'clunky' but workable solution in place that can be adapted to get what you want.

    It uses a VB script from this site, its primary purpose is to restrict student logins to a single login only, but it also logs all logons and logoffs to a text based log file.

    I've then written a PHP script (which is run every minute as a scheduled task) that examines the last 50 entries of this log file and updates a mySQL database with who has logged on or off during that last minute. There's then another PHP script that outputs this information to a screen in our office giving the usernames and machine names of all logged on users in the school. (This could be easily adapted so it will only output names of people logged on in a specific room.)

    It's not the best solution as it takes some server processing time every minute to examine the logfile, and it's only updated once a minute. The PHP part is very simple but heavy on database querys, however it does work!

    I'm going to adapt the VBscript at some point to use the mySQL database directly rather than use text files like it does at the moment, but what's in place is working so it'll be left as it is for the time being.

    If you're interested, give me a PM.

    Cheers,

    Mike.

  13. #13
    altecsole's Avatar
    Join Date
    Jun 2005
    Location
    Whittington, Lancashire
    Posts
    286
    Thank Post
    40
    Thanked 36 Times in 26 Posts
    Rep Power
    26

    Re: Script to capture logon details and output in webpage

    Quote Originally Posted by maniac
    I'm going to adapt the VBscript at some point to use the mySQL database directly rather than use text files like it does at the moment, but what's in place is working so it'll be left as it is for the time being.
    The script I wrote for our school logs logon and logoffs directly to a mySQL database. If you get stuck give me a shout.

  14. #14
    Hawes29's Avatar
    Join Date
    May 2008
    Location
    Oldham
    Posts
    29
    Thank Post
    2
    Thanked 6 Times in 5 Posts
    Rep Power
    15

    Smile Script to capture logon details and output in webpage

    Hi Altecole

    Would it be possible to have a copy of your scritp showing login details and have go into mysql. We would really appreciate it.

    Cheers

    hawes29

  15. #15

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    @triggmeister, the reason your script won't work is this line:
    Code:
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    What it's trying to do is to connect to the remote computer using the credentials of the user running the web page - this will vary depending on the version of IIS but it's almost certainly not going to be a user with admin rights!

    What you can do if you want to go down this route is to specify credentials for a user who is able to connect:
    Code:
    <%
    sComputer = "ma613-03"
    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objSWbemServices = objSWbemLocator.ConnectServer _
        (sComputer, "root\cimv2", "domain\username", "ReallySecretPassword")
    objSWbemServices.Security_.ImpersonationLevel = 3
    
    Set colComputer = objSWbemServices.ExecQuery("Select * from Win32_ComputerSystem")
    sUser="Free"
    For Each objComputer in colComputer
      if objComputer.UserName<>"" then sUser=objComputer.UserName
    next
    response.write sUser
    %>
    This connects to the machine with credentials and then does your query. I've added a bit to it to cope with no user logged on - that may not be important!

    The benefit of a method like this is that it's "live" - you're not relying on a database which could be out of date but the downside is that it takes a little while for the web page to query each computer, particularly if any machines are switched off or restarting etc.



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. logon script for printer
    By ozzy in forum Scripts
    Replies: 6
    Last Post: 22nd November 2007, 04:03 PM
  2. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 12:00 PM
  3. BGInfo in logon script example?
    By ninjabeaver in forum How do you do....it?
    Replies: 16
    Last Post: 24th August 2007, 01:49 PM
  4. Yet another Logon Script
    By ajbritton in forum Windows
    Replies: 3
    Last Post: 19th June 2006, 10:47 AM
  5. Stupid CMD error with logon script
    By tarquel in forum Windows
    Replies: 37
    Last Post: 14th June 2006, 10:07 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
  •