+ Post New Thread
Results 1 to 15 of 15
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 ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200

    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?

  2. #2

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    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.

  3. #3

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    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 ?

  4. #4

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    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.

  5. #5


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,706
    Thank Post
    354
    Thanked 807 Times in 722 Posts
    Rep Power
    348
    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.

  6. #6
    Richie's Avatar
    Join Date
    May 2007
    Location
    Somewhere in Derbyshire
    Posts
    23
    Thank Post
    1
    Thanked 3 Times in 3 Posts
    Rep Power
    16

    Tracking users

    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") = ""
    End Sub


    You then have 2 Sub routines, as below

    Sub Session_Start(ByVal sender as Object, ByVal e as EventArgs)
    Application("UserList") = Application("UserList") & <Username> & ","
    End Sub

    Sub Session_End(ByVal sender as Object, ByVal e as EventArgs)
    Application("UserList").Replace(<Username> & ",", "")
    End Sub


    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.

  7. #7

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    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

  8. #8

    Join Date
    Apr 2007
    Location
    Corby, Northants
    Posts
    48
    Thank Post
    8
    Thanked 9 Times in 8 Posts
    Rep Power
    17
    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

    Maria

  9. #9

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125
    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.

  10. #10

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    I was hoping to just to be able to view who was accessing the site at any given time

  11. #11

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,271
    Thank Post
    884
    Thanked 2,749 Times in 2,322 Posts
    Blog Entries
    11
    Rep Power
    785
    This is the code that you are after I think:
    ASP 101 - Articles

  12. Thanks to SYNACK from:

    RabbieBurns (2nd October 2008)

  13. #12

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Thanks, thats pretty neat:

    Code:
    Session Id 	IP Address  	User Agent  	Session Start Time
    
    696087857  	127.0.0.1  	Mozilla/5.0 ...  02/10/2008 21:34:49
    So is it impossible for me to tell what AD username is being used for each?

  14. #13

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    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

    Code:
    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

  15. #14

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Quote Originally Posted by RabbieBurns View Post

    Works great here on the laptop. Will test it out tomorrow
    Worked last night on XP Pro IIS.

    Doesnt seem to work with 2003 IIS

  16. #15

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Quote Originally Posted by RabbieBurns View Post
    Worked last night on XP Pro IIS.

    Doesnt seem to work with 2003 IIS
    got it working. I didnt use a big enough field and thats what the problem was

    Thanks SYNACK works like a charm



SHARE:
+ Post New Thread

Similar Threads

  1. some [more] asp help required please
    By RabbieBurns in forum Web Development
    Replies: 9
    Last Post: 17th September 2008, 04:40 AM
  2. ASP Host
    By Hightower in forum Web Development
    Replies: 14
    Last Post: 30th June 2008, 09:09 PM
  3. ASP help
    By kerrymoralee9280 in forum Web Development
    Replies: 12
    Last Post: 3rd October 2007, 09:11 AM
  4. ASP Guestbook
    By AnnDroyd in forum Web Development
    Replies: 3
    Last Post: 26th September 2007, 11:46 AM
  5. Front-end IIS server, forward requests to Back-end IIS
    By ryan_powell in forum How do you do....it?
    Replies: 5
    Last Post: 18th October 2006, 11:38 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
  •