Web Development Thread, asp / iis question in Coding and Web Development; anyone know if its possible with built in server commands to get a list of all the people currently authenticated ...
1st October 2008, 09:23 PM #1
asp / iis question
anyone know if its possible with built in server commands to get a list of all the people currently authenticated to IIS with windows integrated authentication. I can get it showing the current logged in user with Request.ServerVariables ("LOGON_USER") but I want to see everyone?
IDG Tech News
1st October 2008, 09:29 PM #2
No, since HTML is a stateless protocol - the user is only 'logged in' for the amount of time that it takes to generate and deliver the requested resource, after that they disappear.
1st October 2008, 09:34 PM #3
i dont allow guest access so they need to enter their domain username and password to access the site. they are authenticated with this the whole time they are on the site.
is there no way to read these from the server ?
1st October 2008, 09:38 PM #4
That's not quite what I meant. During a request for a resource, eg a web page or an image, the browser opens a connection to the server, authenticates, gets the resource, and then closes the connection. Next resource, same process. In practice, modern browsers tend to re-use the same connection to make it faster, but the point is: in between requests, there is no persistent information for the user, which is why it is called a stateless protocol. Unless you happen to have a look at the very moment they are fetching a resource, you won't see them.
1st October 2008, 09:50 PM #5
Perhaps inefficient but you could have them create a temp file like a lockfile which is valid for 5 minutes before being nuked so you could just read from that list.
1st October 2008, 10:06 PM #6
Powdarrmonkey is right, there is no way of reading this information directly from the server.
To provide a list of users similar to the on on the left of the edugeek front page is quite a simple process with IIS.
If you are running ASP.NET, then you can create a Global.asax page at the root folder of your site.
First, setup an Application variable in this file, this will be an array of usernames:
Sub Application_Start(ByVal sender as Object, ByVal e as EventArgs)
Application("UserList") = ""
You then have 2 Sub routines, as below
Sub Session_Start(ByVal sender as Object, ByVal e as EventArgs)
Application("UserList") = Application("UserList") & <Username> & ","
Sub Session_End(ByVal sender as Object, ByVal e as EventArgs)
Application("UserList").Replace(<Username> & ",", "")
These routines run whenever a session is started or closed on IIS. The first adds the current username to a comma separated string, the second removes it.
The Application("Usernames") string is available to use in any of your webpages, again as a comma separated list. You could use the Split method to break this down to an array if you need to.
Sorry this is a bit crude and there may be a more refined way of doing this but this is just off the top of my head.
2nd October 2008, 12:58 PM #7
Thanks for the replies. Its just regular asp not .net.
Its not really important I was just wanting to see if there was an easy way to see how often the site was being used. I guess I can just check the server logs
2nd October 2008, 06:58 PM #8
- Rep Power
How about a single table database, where upon connection / page request, a row is added - ID, Name (From "LOGON_USER"), DateTime (=Now()).
Then, on the page where you are trying to get the current users, try
Dim Now = Now()
Dim fiveMin = Now - 5 Minutes (Not sure on syntax for this)
"SELECT * FROM TableName WHERE DateTime < fiveMin"
Bit of a clunky solution, bit it would probably work. I'd also look at implementing a batch script or something to clear out the table at regular intervals, as it will grow fairly quickly.
Also, You'd then need to remove duplicate names on the current users page, as a user could view page index.asp at 11:00, and again at 11:01, therefore creating two entries.
Hope this helps
2nd October 2008, 09:29 PM #9
In standard ASP, you can use the file global.asa and run code based on session_start and session_end to track the start/end of a sesion. this code could (eg) write the name to a database table at session_start and then remove it at session_end.
What are you trying to do? there might be a better way of achieving it.
2nd October 2008, 09:37 PM #10
I was hoping to just to be able to view who was accessing the site at any given time
2nd October 2008, 10:04 PM #11
This is the code that you are after I think:
ASP 101 - Articles
Thanks to SYNACK from:
RabbieBurns (2nd October 2008)
2nd October 2008, 10:39 PM #12
Thanks, thats pretty neat:
So is it impossible for me to tell what AD username is being used for each?
Session Id IP Address User Agent Session Start Time
696087857 127.0.0.1 Mozilla/5.0 ... 02/10/2008 21:34:49
2nd October 2008, 10:45 PM #13
Actually, I have added in a field in the global.asa and the test_page.asp to include the "LOGON_USER" server field.
Works great here on the laptop. Will test it out tomorrow
Session Id IP Address User Agent Username Session Start Time
696087858 127.0.0.1 Mozilla/5.0 ... VGNTZ\robert 02/10/2008 21:44:11
3rd October 2008, 10:53 AM #14
Worked last night on XP Pro IIS.
Originally Posted by RabbieBurns
Doesnt seem to work with 2003 IIS
7th October 2008, 11:22 AM #15
got it working. I didnt use a big enough field and thats what the problem was
Originally Posted by RabbieBurns
Thanks SYNACK works like a charm
By RabbieBurns in forum Web Development
Last Post: 17th September 2008, 04:40 AM
By Hightower in forum Web Development
Last Post: 30th June 2008, 09:09 PM
By kerrymoralee9280 in forum Web Development
Last Post: 3rd October 2007, 09:11 AM
By AnnDroyd in forum Web Development
Last Post: 26th September 2007, 11:46 AM
By ryan_powell in forum How do you do....it?
Last Post: 18th October 2006, 11:38 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)