In the Global.asax.cs of your ASP.NET site:
Using the current windows authenticated username pass this to our webservice which will pass us back info about this user which we can use in our system
/// <summary> /// Handles the Start event of the Session control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Session_Start(object sender, EventArgs e) { Session["EhapUser"] = UserServiceManager.GetEHAPUser(HttpContext.Current.User.Identity.Name.Remove(0, 5)); }
Then in your MasterPage code behind:
Reference the object that is now in session
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EHAPUser user = (EHAPUser)Session["EhapUser"]; if(user == null) lblLogon.Text = HttpContext.Current.User.Identity.Name; else lblLogon.Text = user.FullName; lblApplicationVersion.Text = ConfigurationManager.AppSettings["applicationVersion"]; } ErrorMessage = null; }
Advertisements