Advertisement
| 04.07.2008 at 09:59AM PDT, ID: 23301982 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
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: |
HERE IS THE LOGIN ASPX CODE AFTER THE USER HAS BEEN AUTHENTICATED
FormsAuthentication.Initialize();
FormsAuthentication.HashPasswordForStoringInConfigFile(edtPassword.Text,"md5");
// Create a new ticket used for authentication
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(
1, // Ticket version
Convert.ToString(UserID), // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(30), // Date/time to expire
true, // "true" for a persistent user cookie
UserRole, // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);// Path cookie valid for
// Encrypt the cookie using the machine key for secure transport
string Hash = FormsAuthentication.Encrypt(Ticket);
HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, Hash);
// Set the cookie's expiration time to the tickets expiration time
if (Ticket.IsPersistent) Cookie.Expires = Ticket.Expiration;
// Add the cookie to the list for outgoing response
Response.Cookies.Add(Cookie);
// Redirect to requested URL, or homepage if no previous page
// requested
//ReturnUrl = Request.QueryString["ReturnUrl"];
string ReturnUrl="";
if (UserRole==c.RoleStudent)
ReturnUrl = c.PageReportViewer;
else
ReturnUrl = c.PageMain;
if (ReturnUrl == null) ReturnUrl = "/";
// Don't call FormsAuthentication.RedirectFromLoginPage since it could replace the authentication ticket (cookie) we just added
Response.Redirect(ReturnUrl);
IN GLOBAL ASPX--------------------
void Application_AuthenticateRequest (Object sender, EventArgs e)
{
if (HttpContext.Current.User != null)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
if (HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity ID = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket Ticket = ID.Ticket;
// Get the stored user-data, in this case, our roles
string UserData = Ticket.UserData;
string[] Roles = UserData.Split(',');
HttpContext.Current.User = new GenericPrincipal(ID,Roles);
}
}
}
}
//---SNIPPET FROM MY CONFIG FILE FOR THE LOGIN APP
<authentication mode="Forms">
<forms name="ilrpts_frms_auth" loginUrl="Login.aspx" protection="All" slidingExpiration="true" timeout="20" path="/"/>
</authentication>
<customErrors mode="Off"/>
<sessionState mode="InProc" timeout="60"/>
...
...
...
<location path="StateList.aspx">
<system.web>
<authorization>
<allow roles="ILAdmin"/>
<deny users="*"/>
</authorization>
</system.web>
...
</location>
|
Advertisement