Current location: Hot Scripts Forums » Programming Languages » ASP.NET » [SOLVED] trying to record the username of the logged in person and the date through s


[SOLVED] trying to record the username of the logged in person and the date through s

Reply
  #1 (permalink)  
Old 04-16-08, 09:58 AM
KamalRahman KamalRahman is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes [SOLVED] trying to record the username of the logged in person and the date through s

hi there im trying to record values from when a user logs in. for instance catching their ip address and so. so far i've managed to catch a few of the details as shown below in the screen shot.

heres the code for the aspx.cs file

session/.........
asp Code:
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (Session["ScreenResolution"] == null)
  4.         {//therefore the session variable is not set
  5.             //in other words redirect to the screen resolution detection script
  6.             Response.Redirect("detect.aspx");
  7.         }
  8.         else
  9.         {
  10.             //Session variable is set
  11.             //so therefore display it on the page
  12.             Session["test"] = "test";
  13.             txtIPaddress.Text = Request.ServerVariables["Remote_Host"];
  14.             txtBrowser.Text = Request.ServerVariables["HTTP_USER_AGENT"];
  15.             txtSessionID.Text = Session.SessionID.ToString();
  16.             txtPage.Text = Request.ServerVariables["URL"];
  17.             txtScreenResolution.Text = Session["ScreenResolution"].ToString();
  18.             AccessDataSource1.Insert();
  19.             AccessDataSource1.DataBind();
  20.         }
  21.         //unless a session is used a new sessionID gets allocated.
  22.     }

please help!!!!!

how can i record the date and username!

thank you
Attached Images
File Type: gif screenshot.GIF (21.3 KB, 195 views)

Last edited by Nico; 04-16-08 at 10:02 AM.
Reply With Quote
  #2 (permalink)  
Old 04-16-08, 10:46 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Are you trying to get the get the Windows Login Username and Time last logged in, OR are you trying to find the username and last login for an ASP.NET based custom login system?

If you are trying to find the username and last login for a custom login system, the easiest way to do it is to set a session variable and assign those 2 to it on the "login" page.

If you are trying to find the user's domain information however, Here is a complete list of Server Variables:


To print out what's in all of them on the page, just do:

C-Sharp Version:

csharp Code:
  1. string lsServerVariableName = "";
  2.    
  3. foreach ( lsServerVariableName in Request.ServerVariables.AllKeys)
  4. {
  5.         Response.Write(lsServerVariableName + ": " + Request.ServerVariables(lsServerVariableName) + "<br />");
  6. }
  7.    
  8. Response.Write("<br />");

Or in VB.NET:

vb.net Code:
  1. Dim lsServerVariableName As String = ""
  2. For Each lsServerVariableName In Request.ServerVariables.AllKeys
  3.  Response.Write(lsServerVariableName & ": " & Request.ServerVariables(lsServerVariableName) & "<br />")
  4. Next
  5. Response.Write("<br />")

The one you want is "LOGON_USER".


Pete
__________________

Last edited by digioz; 04-16-08 at 11:17 AM.
Reply With Quote
  #3 (permalink)  
Old 04-21-08, 11:18 AM
KamalRahman KamalRahman is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
but in asp.net, where do i put the value in to get the user name
Reply With Quote
  #4 (permalink)  
Old 04-21-08, 01:47 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Quote:
Originally Posted by KamalRahman View Post
but in asp.net, where do i put the value in to get the user name
hmm... I don't understand your question. If this is a windows domain username, the value is put in when the user logs into windows. If its a custom asp.net login system, the value is put in when the user enters their username in the login form and submits it.
__________________
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 02:36 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.