triggmiester Posted October 4, 2007 Posted October 4, 2007 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??
Geoff Posted October 4, 2007 Posted October 4, 2007 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.
ChrisH Posted October 4, 2007 Posted October 4, 2007 Surely your not advocating changing the GINA Geoff?????
plexer Posted October 4, 2007 Posted October 4, 2007 Indeed using your own gina is fine it's is modifying the MS one that is not allowed. Ben
altecsole Posted October 4, 2007 Posted October 4, 2007 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
Gatt Posted October 4, 2007 Posted October 4, 2007 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..
Geoff Posted October 4, 2007 Posted October 4, 2007 The MySQL logger for pGINA will log that information for you.
altecsole Posted October 4, 2007 Posted October 4, 2007 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...
Gatt Posted October 4, 2007 Posted October 4, 2007 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... :? 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
altecsole Posted October 4, 2007 Posted October 4, 2007 Okay. Here's some WMI to get the NIC type, MAC, IP and subnet.getnicdetails.vbs
maniac Posted October 4, 2007 Posted October 4, 2007 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.
altecsole Posted October 5, 2007 Posted October 5, 2007 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.
Hawes29 Posted March 31, 2010 Posted March 31, 2010 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
srochford Posted March 31, 2010 Posted March 31, 2010 @triggmeister, the reason your script won't work is this line: 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: <% 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.
ANB Posted June 18, 2010 Posted June 18, 2010 I wrote a little app quite a while ago that ran when a user logged in or out and then updated a MySQL database. I never got around to making any web pages though, and never made it into a full blown app. My intention was to write another app that would display all the computers in the room (after the teacher selected one) and display who was logged on it, but I never got around to it. If you're interested then email me at [email protected]. You're more than welcome to try it out and see if it meets your needs. Adam
browolf Posted June 18, 2010 Posted June 18, 2010 quirky but simple our login script contains the cmd echo %time% %username% > \\server\logs$\users\%computername%.txt if your computers have room prefixes on their names then each file gives the information: room, computer, logged on user it would be easy to make an asp page that searches for the correct files for a room prefix given in the url and displays the information. my scripts here aren't helpful as they're tied into isa server and do a load of wierd isa stuff that isn't relevant.
dayzd Posted June 18, 2010 Posted June 18, 2010 Urr, is this of any use? EduGeek.net - Announcing the EduGeek Logon Tracker
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now