Home All Groups Group Topic Archive Search About

HttpContext.Current.User.IsInRole

Author
12 Dec 2005 12:56 PM
Julia
Hi,
In my asp.net app I am using this code:

FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(
    1,
    lcred.UserName,
    DateTime.Now,
    DateTime.Now.AddMinutes(ldExpiration),
    false,       
    lsRoles
    );

lsRoles is a string with all roles (separated with "|").

When I later use the HttpContext.Current.User.IsInRole method it works fine
on my developer machine but not on my production machine... what can be wrong.

Thanks

Author
12 Dec 2005 1:17 PM
Karl Seguin
From what you've shown us, you aren't doing enough to get it work (not sure
why it's working in dev).

Take a look at:
http://www.codeproject.com/aspnet/AspNetCustomAuth.asp

But you should be getting the roles (from the cookie if they are there, or
from wherever else if they aren't) and creating a new IPrincipal user which
you assign to the Context.User.

Karl
Show quoteHide quote
"Julia" <Ju***@discussions.microsoft.com> wrote in message
news:AE811E42-4A85-49C3-B1B6-E6EF227A3731@microsoft.com...
> Hi,
> In my asp.net app I am using this code:
>
> FormsAuthenticationTicket ticket =
> new FormsAuthenticationTicket(
> 1,
> lcred.UserName,
> DateTime.Now,
> DateTime.Now.AddMinutes(ldExpiration),
> false,
> lsRoles
> );
>
> lsRoles is a string with all roles (separated with "|").
>
> When I later use the HttpContext.Current.User.IsInRole method it works
> fine
> on my developer machine but not on my production machine... what can be
> wrong.
>
> Thanks

Bookmark and Share