Re: IsInRole problem
From: yogaboy (yogaboy.1ym8y1_at_mail.codecomments.com)
Date: 11/16/05
- Next message: Joe Kaplan \(MVP - ADSI\): "Re: forms authentication with domain account from DMZ?"
- Previous message: yoyo44: "Re: Deploy .aspx, browse, get 404 error"
- Maybe in reply to: Patrick Allmond - Focus Consulting Inc: "Re: IsInRole problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 16 Nov 2005 08:55:08 -0600
I've been having the same problem. I used the same code to output
(qouted below), and I hard-coded in the string "Admin,User" when
setting up the ticket.
What I've noticed is that the string doesn't get written to UserData in
the cookie. So this (I think) is where the problem lies...
Code:
--------------------
string ROLE = "Admin,User"
if (authentic)
{
FormsAuthentication.Initialize();
FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket(1, userid, DateTime.Now, DateTime.Now.AddMinutes(30), true, ROLE , FormsAuthentication.FormsCookiePath);
--------------------
when setting up the ticket it's not taking the ROLE properly, so you
can't get the roles back out of the cookie.
Colin Peters wrote:
> *
> So I thought I'd investigate myself. I found by outputing to the page
> in
> the prod environment, that I get the right roles via:
>
> 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(',');
>
> so I know the roles are stored int he cookie OK.
>
> *
-- yogaboy ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------
- Next message: Joe Kaplan \(MVP - ADSI\): "Re: forms authentication with domain account from DMZ?"
- Previous message: yoyo44: "Re: Deploy .aspx, browse, get 404 error"
- Maybe in reply to: Patrick Allmond - Focus Consulting Inc: "Re: IsInRole problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|