Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Last 10 users

    Or so,
    Any code samples?

    I am Looking to pull from the server request variables, (Authenticating via
    windows authentication on my intranet site) and show only the last 10 Unique
    users (Along with their login ID/Displayname) to visit a page, and the
    date/time they've done so... (Keeping the most recent date/time only for dup
    entries.)

    I can write to a sql database table no problem, just looking for a good
    approach before I reinvent the wheel from scratch..

    Thank you in advance..


    Anthony Guest

  2. Similar Questions and Discussions

    1. License.Limit.Exceeded with 4x150 users licence andonly 300 real users
      As indicated by the ongoing discussion, this issue can have different causes - can you describe your application a little bit? How many users are...
    2. License.Limit.Exceeded with 4x150 users licence and only300 real users
      We have 4x150 users licence, set to unlimited bandwith. We get these messages in event viewer: Connection rejected by server. Reason : :...
    3. select all users whose emails belong to two or more users
      Say I wanted to create a query to select all the users whose emails belong to two or more users. How would I go about doing this? Here's what I...
    4. Enable additional users properties in Active Directory users and Computers
      "Mike Brannigan " <mikebran@online.microsoft.com> wrote in message news:O5qGXY1XEHA.808@tk2msftngp13.phx.gbl......
    5. Prevent Power Users from Adding New Users
      >Some of the applications on the computer require users to Download NTREGMON and NTFILMON from www.sysinternals.com. Logon as domain user and run...
  3. #2

    Default Re: Last 10 users

    Just create a table in SQL Server,

    CREATE TABLE UserLogins
    (
    UserName VARCHAR(64) PRIMARY KEY,
    dt SMALLDATETIME DEFAULT GETDATE()
    )
    GO

    Then in session_onstart, call a stored procedure:

    CREATE PROCEDURE dbo.user_trackLogin
    @username VARCHAR(64)
    AS
    BEGIN
    SET NOCOUNT ON
    UPDATE UserLogins
    SET dt = GETDATE() WHERE
    UserName = @username
    IF @@ROWCOUNT = 0
    INSERT UserLogins(UserName)
    VALUES(@username)
    END
    GO

    Using something like this in global.asa:

    sub session_onstart()
    set conn = CreateObject("ADODB.Connection")
    conn.open "connection string"
    un = Request.ServerVariables("LOGON_USER")
    un = replace(un, "'", "''")
    conn.execute("EXEC user_trackLogin '" & un & "'")
    conn.close: set conn = nothing
    end sub

    Then to get the most recent 10:

    CREATE PROCEDURE dbo.user_listTop10
    AS
    BEGIN
    SET NOCOUNT ON
    SELECT TOP 10 UserName, dt
    FROM UserLogins
    ORDER BY dt DESC
    END
    GO

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Anthony" <antgoodlife@nospam.comcast.net> wrote in message
    news:#jwF5O83DHA.360@TK2MSFTNGP12.phx.gbl...
    > Or so,
    > Any code samples?
    >
    > I am Looking to pull from the server request variables, (Authenticating
    via
    > windows authentication on my intranet site) and show only the last 10
    Unique
    > users (Along with their login ID/Displayname) to visit a page, and the
    > date/time they've done so... (Keeping the most recent date/time only for
    dup
    > entries.)
    >
    > I can write to a sql database table no problem, just looking for a good
    > approach before I reinvent the wheel from scratch..
    >
    > Thank you in advance..
    >
    >

    Aaron Bertrand [MVP] Guest

  4. #3

    Default Re: Last 10 users

    Thank you Aaron, I've already obtained the username from the Logon_user.. so
    I won't need that piece.. but it's good to post it.. (What exactly is the
    difference between auth_user and logon_user anyway? regardless, I'll look
    towards using this in the asp. And the stored procedures will be a first run
    in my repertoire..

    Thank you very much for the quick reply

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/ref_ssi_echo.asp[/url]

    tells me the difference so there is no need to answer.. but figured i'd
    share..
    --
    Anthony B
    ------------------------
    Expansion Slots: The extra holes in your belt buckle

    "Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
    news:eO$rVY83DHA.1704@tk2msftngp13.phx.gbl...
    > Just create a table in SQL Server,
    >
    > CREATE TABLE UserLogins
    > (
    > UserName VARCHAR(64) PRIMARY KEY,
    > dt SMALLDATETIME DEFAULT GETDATE()
    > )
    > GO
    >
    > Then in session_onstart, call a stored procedure:
    >
    > CREATE PROCEDURE dbo.user_trackLogin
    > @username VARCHAR(64)
    > AS
    > BEGIN
    > SET NOCOUNT ON
    > UPDATE UserLogins
    > SET dt = GETDATE() WHERE
    > UserName = @username
    > IF @@ROWCOUNT = 0
    > INSERT UserLogins(UserName)
    > VALUES(@username)
    > END
    > GO
    >
    > Using something like this in global.asa:
    >
    > sub session_onstart()
    > set conn = CreateObject("ADODB.Connection")
    > conn.open "connection string"
    > un = Request.ServerVariables("LOGON_USER")
    > un = replace(un, "'", "''")
    > conn.execute("EXEC user_trackLogin '" & un & "'")
    > conn.close: set conn = nothing
    > end sub
    >
    > Then to get the most recent 10:
    >
    > CREATE PROCEDURE dbo.user_listTop10
    > AS
    > BEGIN
    > SET NOCOUNT ON
    > SELECT TOP 10 UserName, dt
    > FROM UserLogins
    > ORDER BY dt DESC
    > END
    > GO
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >
    >
    >
    > "Anthony" <antgoodlife@nospam.comcast.net> wrote in message
    > news:#jwF5O83DHA.360@TK2MSFTNGP12.phx.gbl...
    > > Or so,
    > > Any code samples?
    > >
    > > I am Looking to pull from the server request variables, (Authenticating
    > via
    > > windows authentication on my intranet site) and show only the last 10
    > Unique
    > > users (Along with their login ID/Displayname) to visit a page, and the
    > > date/time they've done so... (Keeping the most recent date/time only for
    > dup
    > > entries.)
    > >
    > > I can write to a sql database table no problem, just looking for a good
    > > approach before I reinvent the wheel from scratch..
    > >
    > > Thank you in advance..
    > >
    > >
    >
    >

    Anthony Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139