Uhg!!
None of the above posts seem to help me in my situation. I am new to ASP.Net. I am working on a loginCheck.aspx page with a codeFile of loginCheck.aspx.cs
loginCheck.aspx:
<%@ Page Language="C#" debug="true" CodeFile="loginCheck.aspx.cs" Inherits="JMUAuthSample.CustomIdentity" %>
<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e) {
Response.Write("loginCheck.aspx - " + Server.HtmlEncode(User.Identity.Name) + "<br>");
Response.Write("loginCheck.aspx - " + HttpContext.Current.User + "<br>");
if (HttpContext.Current.User != null) {
Response.Write("loginCheck.aspx - " + HttpContext.Current.User.Identity.IsAuthenticated + "<br>");
if (HttpContext.Current.User.Identity.IsAuthenticated) {
Response.Write("loginCheck.aspx - " + HttpContext.Current.User.Identity.Name + "<br>");
Response.Write("Session - " + Session.Contents["domainName"] + "<br>");
Response.Write("loginCheck.aspx - " + (HttpContext.Current.User.Identity is FormsIdentity) + "<br>");
if ((HttpContext.Current.User.Identity is FormsIdentity)) {
Response.Write("blah1<br>");
//System.Security.Principal.GenericPrincipal principal = (System.Security.Principal.GenericPrincipal)HttpContext.Current.User;
//FormsIdentity id = (FormsIdentity)principal.Identity;
//Response.Write("loginCheck.aspx - id.Name - " + id.Name + "<br>");
//CustomIdentity ident = new CustomIdentity(id);
// HttpContext.Current.User = new System.Security.Principal.GenericPrincipal( ident, ** usersroles ** );
}
}
}
//Response.Redirect("loadSession.asp?uid=" + Server.HtmlEncode(User.Identity.Name) + "&domain=" + Session.Contents["domainName"]);
}
</script>
loginCheck.aspx.cs:
using System;
using System.Web.UI;
using System.Collections.Specialized;
using System.Security.Principal;
using System.Xml;
namespace JMUAuthSample {
public partial class CustomIdentity : IIdentity {
private bool _bIsAuthenticated;
private string _sAuthenticationType;
private string _sUserName;
private string _sFirstName;
private string _sLastName;
private StringCollection _lstRoles = new StringCollection();
public CustomIdentity(string sUserName, bool bIsAuthenticated, string sAuthenticationType)
{
_sUserName = sUserName;
_bIsAuthenticated = bIsAuthenticated;
_sAuthenticationType = sAuthenticationType;
}
/// <summary>
/// The type of authentication used.
/// </summary>
public string AuthenticationType //Required by IIdentity
{
get { return _sAuthenticationType; }
}
/// <summary>
/// Indicates whether user has been authenticated.
/// </summary>
public bool IsAuthenticated //Required by IIdentity
{
get { return _bIsAuthenticated; }
}
/// <summary>
/// The unique name of the user.
/// </summary>
public string Name //Required by IIdentity
{
get { return _sUserName; }
}
/// <summary>
/// The user’s last name.
/// </summary>
public string FirstName //For the ‘firstName’ attribute.
{
get { return _sFirstName; }
set { _sFirstName = value; }
}
/// <summary>
/// The user’s first name.
/// </summary>
public string LastName //For the ‘lastName’ attribute.
{
get { return _sLastName; }
set { _sLastName = value; }
}
/// <summary>
/// A list of roles the user is a member of.
/// </summary>
public StringCollection Roles //For the ‘role’ elements.
{
get { return _lstRoles; }
}
}
}
I don't understand why the GetTypeHashCode() function is being loaded or in this case overloaded in the first place. The JMUAuthSample Namespace is a renamed namespace for testing, but I pulled the code from some code site. Ultimately I don't understand how to make a namespace work in a codefile.
Any help would be appreciated.