User.IsInRole is always FALSE

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default User.IsInRole is always FALSE

    Hi, I have the following problem...

    Pre-requisites:
    Installation of an Asp.net webservice on a IIS5 server (win2k). Anonymous
    access is not allowed, only using windows authentication (intranet app),
    webmethoda are using the Principalpermssion attribute
    ([PrincipalPermission(SecurityAction.Demand,
    Role=@"DomainName\WindowsGroup...")]) for identification.

    Result --> does not work

    When I change the to [PrincipalPermission(SecurityAction.Demand,
    name=@"DomainName\Windowsuser...")]) -> it runs fine

    --> conclusion: IIS cannot determine if a user belongs to an AD group -->
    IPrincipal.IsInRole(@"DomainName\WindowsGroup") is always FALSE!

    I already found an article on the web
    ([url]http://www.kbalertz.com/kb_894432.aspx[/url] --> web dir is UNC share), but
    didn't solved the problem...

    Does anyone know more about this issue?

    Thanks
    Oliver Rainer



    Oliver Rainer Guest

  2. Similar Questions and Discussions

    1. HttpContext.Current.User.IsInRole
      Hi, I have a problem when I am using the HttpContext.Current.User.IsInRole... This is my code: if (HttpContext.Current.User.IsInRole("Admin...
    2. isInRole doesn't work for one user, but works for everyone else
      I have an ASP.NET/C# application in which I verify that the current user is a member of a list of roles before giving them access to particular...
    3. HttpContext.Current.User.IsInRole(string) always returns false
      I have a asp.net 1.1 site and HttpContext.Current.User.IsInRole(@"MyLocalComputer\MyGroup") always returns false. I've turned off anonymous...
    4. ASP.NET Context.User.IsInRole XP Problem
      Hi guys I am having a problem with the following line of code on Windows XP Pro. The variable userRole is a string depicting my role on the local...
    5. User.IsInRole not redirecting
      Hi there, I have been reading up on Authorization and role based security for a couple of days now, and am trying to implement this in my...
  3. #2

    Default Re: User.IsInRole is always FALSE

    June 7, 2005

    hehe I actually have to go to a meeting right now, but a quick suggestion
    before I leave. Try switching the PrincipalPermission
    role="domain\groupname" to "BUILTIN\GROUPNAME". There is a little more to
    this change, but it should work.... depending on which role it is, so if you
    could post it, that would really help... until later! :-)

    --
    Joseph Bittman
    Microsoft Certified Application Developer

    Web Site: [url]http://71.35.110.42[/url]
    Dynamic IP -- Check here for future changes

    "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    news:ubg7WH3aFHA.2440@TK2MSFTNGP10.phx.gbl...
    > Hi, I have the following problem...
    >
    > Pre-requisites:
    > Installation of an Asp.net webservice on a IIS5 server (win2k). Anonymous
    > access is not allowed, only using windows authentication (intranet app),
    > webmethoda are using the Principalpermssion attribute
    > ([PrincipalPermission(SecurityAction.Demand,
    > Role=@"DomainName\WindowsGroup...")]) for identification.
    >
    > Result --> does not work
    >
    > When I change the to [PrincipalPermission(SecurityAction.Demand,
    > name=@"DomainName\Windowsuser...")]) -> it runs fine
    >
    > --> conclusion: IIS cannot determine if a user belongs to an AD group -->
    > IPrincipal.IsInRole(@"DomainName\WindowsGroup") is always FALSE!
    >
    > I already found an article on the web
    > ([url]http://www.kbalertz.com/kb_894432.aspx[/url] --> web dir is UNC share), but
    > didn't solved the problem...
    >
    > Does anyone know more about this issue?
    >
    > Thanks
    > Oliver Rainer
    >
    >
    >

    Joseph Bittman MCAD Guest

  4. #3

    Default Re: User.IsInRole is always FALSE

    Thanks for your suggestion... that really works for local groups (BUILTIN),
    but IIS still has the problem to resolve AD groups (OURDOMAIN\...)... The
    strange thing is that on certain machines (our developer machines), IIS can
    succesfully determine if a user belongs to an AD group...

    Do you have other suggestions??

    Thanks
    Oliver Rainer


    "Joseph Bittman MCAD" <RyanBittman@msn.com> wrote in message
    news:eIRT4F4aFHA.3280@TK2MSFTNGP12.phx.gbl...
    > June 7, 2005
    >
    > hehe I actually have to go to a meeting right now, but a quick suggestion
    > before I leave. Try switching the PrincipalPermission
    > role="domain\groupname" to "BUILTIN\GROUPNAME". There is a little more to
    > this change, but it should work.... depending on which role it is, so if
    you
    > could post it, that would really help... until later! :-)
    >
    > --
    > Joseph Bittman
    > Microsoft Certified Application Developer
    >
    > Web Site: [url]http://71.35.110.42[/url]
    > Dynamic IP -- Check here for future changes
    >
    > "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    > news:ubg7WH3aFHA.2440@TK2MSFTNGP10.phx.gbl...
    > > Hi, I have the following problem...
    > >
    > > Pre-requisites:
    > > Installation of an Asp.net webservice on a IIS5 server (win2k).
    Anonymous
    > > access is not allowed, only using windows authentication (intranet app),
    > > webmethoda are using the Principalpermssion attribute
    > > ([PrincipalPermission(SecurityAction.Demand,
    > > Role=@"DomainName\WindowsGroup...")]) for identification.
    > >
    > > Result --> does not work
    > >
    > > When I change the to [PrincipalPermission(SecurityAction.Demand,
    > > name=@"DomainName\Windowsuser...")]) -> it runs fine
    > >
    > > --> conclusion: IIS cannot determine if a user belongs to an AD
    group -->
    > > IPrincipal.IsInRole(@"DomainName\WindowsGroup") is always FALSE!
    > >
    > > I already found an article on the web
    > > ([url]http://www.kbalertz.com/kb_894432.aspx[/url] --> web dir is UNC share), but
    > > didn't solved the problem...
    > >
    > > Does anyone know more about this issue?
    > >
    > > Thanks
    > > Oliver Rainer
    > >
    > >
    > >
    >
    >

    Oliver Rainer Guest

  5. #4

    Default Re: User.IsInRole is always FALSE

    June 9, 2005

    :-) Yes, the BUILTIN will only work for local groups. AD groups are
    somewhat more mysterious and have had problems with them myself. When you
    call IsInRole, where is the IPrincipal coming from? Are you using the
    interface directly, or using an object taken from the
    System.Threading.Thread.CurrentPrincipal, or the User object???? This makes
    a big difference in the result that you will get, because I believe in your
    case that only a principal taken from User will reflect the user's identity
    and not ASPNET. If you could post how you got Iprincipal.IsInRole, then I
    believe that I can help you further! :-) Have a great day and until later!!!

    --
    Joseph Bittman Beta ID# 678424
    Microsoft Certified Application Developer

    Web Site: [url]http://71.35.110.42[/url]
    Dynamic IP -- Check here for future changes

    "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    news:O$%23NC1$aFHA.1044@TK2MSFTNGP10.phx.gbl...
    > Thanks for your suggestion... that really works for local groups
    > (BUILTIN),
    > but IIS still has the problem to resolve AD groups (OURDOMAIN\...)... The
    > strange thing is that on certain machines (our developer machines), IIS
    > can
    > succesfully determine if a user belongs to an AD group...
    >
    > Do you have other suggestions??
    >
    > Thanks
    > Oliver Rainer
    >
    >
    > "Joseph Bittman MCAD" <RyanBittman@msn.com> wrote in message
    > news:eIRT4F4aFHA.3280@TK2MSFTNGP12.phx.gbl...
    >> June 7, 2005
    >>
    >> hehe I actually have to go to a meeting right now, but a quick
    >> suggestion
    >> before I leave. Try switching the PrincipalPermission
    >> role="domain\groupname" to "BUILTIN\GROUPNAME". There is a little more to
    >> this change, but it should work.... depending on which role it is, so if
    > you
    >> could post it, that would really help... until later! :-)
    >>
    >> --
    >> Joseph Bittman
    >> Microsoft Certified Application Developer
    >>
    >> Web Site: [url]http://71.35.110.42[/url]
    >> Dynamic IP -- Check here for future changes
    >>
    >> "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    >> news:ubg7WH3aFHA.2440@TK2MSFTNGP10.phx.gbl...
    >> > Hi, I have the following problem...
    >> >
    >> > Pre-requisites:
    >> > Installation of an Asp.net webservice on a IIS5 server (win2k).
    > Anonymous
    >> > access is not allowed, only using windows authentication (intranet
    >> > app),
    >> > webmethoda are using the Principalpermssion attribute
    >> > ([PrincipalPermission(SecurityAction.Demand,
    >> > Role=@"DomainName\WindowsGroup...")]) for identification.
    >> >
    >> > Result --> does not work
    >> >
    >> > When I change the to [PrincipalPermission(SecurityAction.Demand,
    >> > name=@"DomainName\Windowsuser...")]) -> it runs fine
    >> >
    >> > --> conclusion: IIS cannot determine if a user belongs to an AD
    > group -->
    >> > IPrincipal.IsInRole(@"DomainName\WindowsGroup") is always FALSE!
    >> >
    >> > I already found an article on the web
    >> > ([url]http://www.kbalertz.com/kb_894432.aspx[/url] --> web dir is UNC share),
    >> > but
    >> > didn't solved the problem...
    >> >
    >> > Does anyone know more about this issue?
    >> >
    >> > Thanks
    >> > Oliver Rainer
    >> >
    >> >
    >> >
    >>
    >>
    >
    >

    Joseph Bittman MCAD Guest

  6. #5

    Default Re: User.IsInRole is always FALSE

    Hi Joseph,

    I executed the following code for testing the stuff --> all booleans were
    false except the local admin groups...

    WindowsPrincipal windowsPrincipal =
    (WindowsPrincipal)Thread.CurrentPrincipal;

    IPrincipal iPrincipal = Thread.CurrentPrincipal;

    WindowsIdentity windowsIdentity =
    System.Security.Principal.WindowsIdentity.GetCurre nt();

    string user = windowsIdentity.Name;


    bool isLocalAdmin =
    windowsPrincipal.IsInRole(WindowsBuiltInRole.Admin istrator);

    bool isInTestgroup1 = windowsPrincipal.IsInRole(@"DOMAIN\Testgroup1");

    bool isInTestgroup2 = windowsPrincipal.IsInRole(@"DOMAIN\Testgroup2");

    bool isLocalAdmin_2 = iPrincipal.IsInRole(@"BUILTIN\Administrators");

    bool isInTestgroup1_2 = iPrincipal.IsInRole(@"DOMAIN\Testgroup1");

    bool isInTestgroup2_2 = iPrincipal.IsInRole(@"DOMAIN\Testgroup2");

    Thanks for your help...

    Oliver Rainer




    "Joseph Bittman MCAD" <RyanBittman@msn.com> wrote in message
    news:OJWiWGEbFHA.3032@TK2MSFTNGP10.phx.gbl...
    > June 9, 2005
    >
    > :-) Yes, the BUILTIN will only work for local groups. AD groups are
    > somewhat more mysterious and have had problems with them myself. When you
    > call IsInRole, where is the IPrincipal coming from? Are you using the
    > interface directly, or using an object taken from the
    > System.Threading.Thread.CurrentPrincipal, or the User object???? This
    makes
    > a big difference in the result that you will get, because I believe in
    your
    > case that only a principal taken from User will reflect the user's
    identity
    > and not ASPNET. If you could post how you got Iprincipal.IsInRole, then I
    > believe that I can help you further! :-) Have a great day and until
    later!!!
    >
    > --
    > Joseph Bittman Beta ID# 678424
    > Microsoft Certified Application Developer
    >
    > Web Site: [url]http://71.35.110.42[/url]
    > Dynamic IP -- Check here for future changes
    >
    > "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    > news:O$%23NC1$aFHA.1044@TK2MSFTNGP10.phx.gbl...
    > > Thanks for your suggestion... that really works for local groups
    > > (BUILTIN),
    > > but IIS still has the problem to resolve AD groups (OURDOMAIN\...)...
    The
    > > strange thing is that on certain machines (our developer machines), IIS
    > > can
    > > succesfully determine if a user belongs to an AD group...
    > >
    > > Do you have other suggestions??
    > >
    > > Thanks
    > > Oliver Rainer
    > >
    > >
    > > "Joseph Bittman MCAD" <RyanBittman@msn.com> wrote in message
    > > news:eIRT4F4aFHA.3280@TK2MSFTNGP12.phx.gbl...
    > >> June 7, 2005
    > >>
    > >> hehe I actually have to go to a meeting right now, but a quick
    > >> suggestion
    > >> before I leave. Try switching the PrincipalPermission
    > >> role="domain\groupname" to "BUILTIN\GROUPNAME". There is a little more
    to
    > >> this change, but it should work.... depending on which role it is, so
    if
    > > you
    > >> could post it, that would really help... until later! :-)
    > >>
    > >> --
    > >> Joseph Bittman
    > >> Microsoft Certified Application Developer
    > >>
    > >> Web Site: [url]http://71.35.110.42[/url]
    > >> Dynamic IP -- Check here for future changes
    > >>
    > >> "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    > >> news:ubg7WH3aFHA.2440@TK2MSFTNGP10.phx.gbl...
    > >> > Hi, I have the following problem...
    > >> >
    > >> > Pre-requisites:
    > >> > Installation of an Asp.net webservice on a IIS5 server (win2k).
    > > Anonymous
    > >> > access is not allowed, only using windows authentication (intranet
    > >> > app),
    > >> > webmethoda are using the Principalpermssion attribute
    > >> > ([PrincipalPermission(SecurityAction.Demand,
    > >> > Role=@"DomainName\WindowsGroup...")]) for identification.
    > >> >
    > >> > Result --> does not work
    > >> >
    > >> > When I change the to [PrincipalPermission(SecurityAction.Demand,
    > >> > name=@"DomainName\Windowsuser...")]) -> it runs fine
    > >> >
    > >> > --> conclusion: IIS cannot determine if a user belongs to an AD
    > > group -->
    > >> > IPrincipal.IsInRole(@"DomainName\WindowsGroup") is always FALSE!
    > >> >
    > >> > I already found an article on the web
    > >> > ([url]http://www.kbalertz.com/kb_894432.aspx[/url] --> web dir is UNC share),
    > >> > but
    > >> > didn't solved the problem...
    > >> >
    > >> > Does anyone know more about this issue?
    > >> >
    > >> > Thanks
    > >> > Oliver Rainer
    > >> >
    > >> >
    > >> >
    > >>
    > >>
    > >
    > >
    >
    >

    Oliver Rainer Guest

  7. #6

    Default Re: User.IsInRole is always FALSE


    Hi Oliver,

    I was able to fix this problem by changing the web.config file fro
    mode="None" to mode="Windows" in the authentication section, e.g.

    <authentication mode="Windows" />

    Cheers

    --
    WirelessBe
    -----------------------------------------------------------------------
    WirelessBen's Profile: [url]http://www.highdots.com/forums/member.php?userid=23[/url]
    View this thread: [url]http://www.highdots.com/forums/showthread.php?t=148294[/url]

    WirelessBen Guest

  8. #7

    Default Re: User.IsInRole is always FALSE

    Thanks for your suggestion...
    I checked the setting in web.configm and it was already set to "Windows"..
    ;-(


    "WirelessBen" <WirelessBen.1qf8c1@no-mx.forums.yourdomain.com.au> wrote in
    message news:WirelessBen.1qf8c1@no-mx.forums.yourdomain.com.au...
    >
    > Hi Oliver,
    >
    > I was able to fix this problem by changing the web.config file from
    > mode="None" to mode="Windows" in the authentication section, e.g.
    >
    > <authentication mode="Windows" />
    >
    > Cheers!
    >
    >
    > --
    > WirelessBen
    > ------------------------------------------------------------------------
    > WirelessBen's Profile:
    [url]http://www.highdots.com/forums/member.php?userid=232[/url]
    > View this thread: [url]http://www.highdots.com/forums/showthread.php?t=1482941[/url]
    >

    Oliver Rainer Guest

  9. #8

    Default Re: User.IsInRole is always FALSE

    Setting up an ASP.Net application to use Windows authentication is generally
    a two step process depending on how your server is configured. You need to
    set the mode atribute of the authentication element to "Windows" as stated.
    The second part that seems to trip people is you need to go the the IIS
    manager console, write click on your application, select properties, select
    the directory security tab, under Anonymous access and authentication
    control select the edit button, make sure Anonymous access is unchecked and
    Integrated Windows authentication is checked. This will now force requests
    to authenticate.

    You should be able to capture the actual requester. You may need to check
    the System.Thread.Threading.CurrentPrincipal,
    System.Web.HttpContext.Current.User, and
    System.Security.Principal.WindowsIdentity.GetCurre nt() to see which one has
    the actual account you need. These values can be different based on your
    configuration settings.

    If you can't find the user in nay of these, you may also need to add an
    identity element to your web.config with the impersonate attribute set to
    true.

    IHTH

    Jon


    "Oliver Rainer" <olrainer@tiscali.ch> wrote in message
    news:uOIRXU%23bFHA.2984@TK2MSFTNGP15.phx.gbl...
    > Thanks for your suggestion...
    > I checked the setting in web.configm and it was already set to "Windows"..
    > ;-(
    >
    >
    > "WirelessBen" <WirelessBen.1qf8c1@no-mx.forums.yourdomain.com.au> wrote in
    > message news:WirelessBen.1qf8c1@no-mx.forums.yourdomain.com.au...
    >>
    >> Hi Oliver,
    >>
    >> I was able to fix this problem by changing the web.config file from
    >> mode="None" to mode="Windows" in the authentication section, e.g.
    >>
    >> <authentication mode="Windows" />
    >>
    >> Cheers!
    >>
    >>
    >> --
    >> WirelessBen
    >> ------------------------------------------------------------------------
    >> WirelessBen's Profile:
    > [url]http://www.highdots.com/forums/member.php?userid=232[/url]
    >> View this thread: [url]http://www.highdots.com/forums/showthread.php?t=1482941[/url]
    >>
    >
    >

    CodeMeister Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139