J
Jules
When creating this website I user a custom authentication method to
validate the usercredentials (I think the membership provider is an
overkill since I only use the authentication part).
When I have a authenticated user I use
FormsAuthentication.RedirectFromLoginPage to authenticate the user in
the ASP.NET context. However, I'd like to add roles to this
GenericPricipal.
Therefore I tried
FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(myUser.Name, false, 30);
FormsIdentity userIdentity = new FormsIdentity(ticket);
GenericPrincipal userPricipal = new GenericPrincipal(userIdentity,
(string[])myUser.Rights.ToArray(System.Type.GetType("System.String")));
HttpContext.Current.User = userPricipal;
Two problems;
1) When I navigate to a different aspx page within my application I
lose this context and I'm not logged in anymore.
2) When I call FormsAuthentication.RedirectFromLoginPage again, I lose
the context also, but ASP.NET creates new one based on the username.
But now I don't have the user-roles anymore.
So:
How can I add roles to my authenticated user in ASP.NET 2.0 when using
FormsAuthentication?
validate the usercredentials (I think the membership provider is an
overkill since I only use the authentication part).
When I have a authenticated user I use
FormsAuthentication.RedirectFromLoginPage to authenticate the user in
the ASP.NET context. However, I'd like to add roles to this
GenericPricipal.
Therefore I tried
FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(myUser.Name, false, 30);
FormsIdentity userIdentity = new FormsIdentity(ticket);
GenericPrincipal userPricipal = new GenericPrincipal(userIdentity,
(string[])myUser.Rights.ToArray(System.Type.GetType("System.String")));
HttpContext.Current.User = userPricipal;
Two problems;
1) When I navigate to a different aspx page within my application I
lose this context and I'm not logged in anymore.
2) When I call FormsAuthentication.RedirectFromLoginPage again, I lose
the context also, but ASP.NET creates new one based on the username.
But now I don't have the user-roles anymore.
So:
How can I add roles to my authenticated user in ASP.NET 2.0 when using
FormsAuthentication?