HttpContext.Current.User.IsInRole(string) always returns false

Discussion in 'ASP .Net Security' started by Randy, Sep 2, 2004.

  1. Randy

    Randy Guest

    I have a asp.net 1.1 site and
    HttpContext.Current.User.IsInRole(@"MyLocalComputer\MyGroup") always returns
    false.

    I've turned off anonymous access in iis, set the impersonate=true in the
    web.config, even tried to impersonate via code using this. I've tried this
    on XP Pro as well as 2003 server with the same results.

    System.Security.Principal.WindowsImpersonationContext
    impersonationContext;
    impersonationContext =

    ((System.Security.Principal.WindowsIdentity)HttpContext.Current.User.Identit
    y).Impersonate();

    WindowsPrincipal myPrincipal =
    (WindowsPrincipal)HttpContext.Current.User;

    bool rc = myPrincipal.IsInRole(role);

    rc = HttpContext.Current.User.IsInRole(role);

    But rc is always false. My HttpContext.Current.User.Identity.Name is
    returning Administrator as it should, but it doesn't recognize any groups
    that i put administrator into.

    Any ideas?

    -Randy
    Randy, Sep 2, 2004
    #1
    1. Advertising

  2. Sometimes group changes require a reboot to update the logon token. Have
    you tried that?

    Another thing to try would be the sample Hernan posted a day or two ago that
    shows how to use reflection to get the list of groups the user is in from
    the private function in the WindowsIdentity class. This is often useful for
    debugging this situation although you don't want to use it in production
    code.

    Joe K.

    "Randy" <randyvATitolDOTcom> wrote in message
    news:%...
    >
    > I have a asp.net 1.1 site and
    > HttpContext.Current.User.IsInRole(@"MyLocalComputer\MyGroup") always

    returns
    > false.
    >
    > I've turned off anonymous access in iis, set the impersonate=true in the
    > web.config, even tried to impersonate via code using this. I've tried

    this
    > on XP Pro as well as 2003 server with the same results.
    >
    > System.Security.Principal.WindowsImpersonationContext
    > impersonationContext;
    > impersonationContext =
    >
    >

    ((System.Security.Principal.WindowsIdentity)HttpContext.Current.User.Identit
    > y).Impersonate();
    >
    > WindowsPrincipal myPrincipal =
    > (WindowsPrincipal)HttpContext.Current.User;
    >
    > bool rc = myPrincipal.IsInRole(role);
    >
    > rc = HttpContext.Current.User.IsInRole(role);
    >
    > But rc is always false. My HttpContext.Current.User.Identity.Name is
    > returning Administrator as it should, but it doesn't recognize any groups
    > that i put administrator into.
    >
    > Any ideas?
    >
    > -Randy
    >
    >
    Joe Kaplan \(MVP - ADSI\), Sep 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVsaWE=?=

    HttpContext.Current.User.IsInRole

    =?Utf-8?B?SnVsaWE=?=, Dec 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,580
    Karl Seguin
    Dec 12, 2005
  2. Dwight Johnson

    HttpContext.Current.User returns old user id

    Dwight Johnson, Feb 16, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    1,264
    Alexey Smirnov
    Feb 28, 2010
  3. Julia

    HttpContext.Current.User.IsInRole

    Julia, Apr 6, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    147
    Joe Kaplan \(MVP - ADSI\)
    Apr 6, 2005
  4. Dave

    IsInRole always returns false?

    Dave, Oct 11, 2005, in forum: ASP .Net Security
    Replies:
    2
    Views:
    525
    Dominick Baier [DevelopMentor]
    Oct 11, 2005
  5. Oliver Rainer

    User.IsInRole is always FALSE

    Oliver Rainer, Jun 7, 2005, in forum: ASP .Net Web Services
    Replies:
    5
    Views:
    235
    Oliver Rainer
    Jun 13, 2005
Loading...

Share This Page