Problems with IsInRole

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

  1. #1

    Default Problems with IsInRole

    I'm having problems with WindowsPrincipal.IsInRole. It's returning false
    when it should return true.

    I've written some test code that uses reflection to call the private
    _GetRoles method of WindowsIdentity. That gets the same list of roles that
    IsInRole uses. It returns a long list, but most of the strings in the list
    are blank (i.e. zero length or null). That explains why IsInRole fails,
    since it's doing lookups in a list that consists of (mostly) empty strings.

    Does anyone know the cause of this behaviour?

    John


    John Rusk Guest

  2. Similar Questions and Discussions

    1. 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...
    2. isInrole
      I am using isInRole function to check if a user is in a group. It works ok except it will suddenly stop working and I will have to reboot to get it...
    3. Help with IsInRole
      Hi, I am using windows integrated authentication aon my intranet. How do I check if a user is a member of a group in active directory. I have the...
    4. IsInRole doesn't works correctly
      In my ASP.NET Application i check whether user that opens application is a member of my created Windows Group(Managers). if...
    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: Problems with IsInRole

    Is it possible that the SID->name resolution might be failing due to a
    security context error? I think the underlying API call requires a domain
    security context on the current thread. You might try impersonating the
    WindowsIdentity in the WindowsPrincipal before you call IsInRole to see if
    that changes your results. You can revert back right after you call
    IsInRole for the first time.

    Let us know if that fixes the problem.

    Joe K.

    "John Rusk" <JohnRusk@discussions.microsoft.com> wrote in message
    news:2BF3DB46-DBFA-4E9D-9FD7-B59346693801@microsoft.com...
    > I'm having problems with WindowsPrincipal.IsInRole. It's returning false
    > when it should return true.
    >
    > I've written some test code that uses reflection to call the private
    > _GetRoles method of WindowsIdentity. That gets the same list of roles
    > that
    > IsInRole uses. It returns a long list, but most of the strings in the
    > list
    > are blank (i.e. zero length or null). That explains why IsInRole fails,
    > since it's doing lookups in a list that consists of (mostly) empty
    > strings.
    >
    > Does anyone know the cause of this behaviour?
    >
    > John
    >
    >

    Joe Kaplan \(MVP - ADSI\) Guest

  4. #3

    Default Re: Problems with IsInRole

    > security context on the current thread. You might try impersonating the
    > WindowsIdentity in the WindowsPrincipal before you call IsInRole to see if
    Joe,

    I wondered about that. I haven't tried it yet at the client's site. What I
    have tried there is the little test application that calls _GetRoles. It's a
    Winforms app, so runs under the account of the logged in domain user. It
    fails as described in my original post, which leads me to believe that doing
    impersonation in ASP probably wouldn't help either.

    Can you think of any explaination why the _GetRoles call should fail? It is
    run by a user logged in to domain "X", but fails to return groups in domain
    "X" to which the user belongs. The only possible complicating factor, at
    least the only one I've thought of so far, is that the machine itself is not
    a member of domain "X".

    John
    John Rusk Guest

  5. #4

    Default Re: Problems with IsInRole

    I think I've found the problem. I think its something like this:

    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;262958[/url]

    While I'm not 100% sure that I'm suffering from _exactly_ the same problem,
    it seems that its possible to configure domain controllers in a way that
    breaks .NET's role based security.

    I ended up dropping .NET's IsInRole, and using equivalent code from Keith
    Brown's security library
    ([url]http://www.theserverside.net/discussions/thread.tss?thread_id=25074[/url]). That
    was when I finally got the error 1789, which means "The trust relationship
    between this workstation and the primary domain failed". It's a shame that
    ..NET's IsInRole doesn't log anything to indicate what's going wrong. The
    only sign was blank/missing names for global groups when I called _GetRoles.

    In the code I used, from Keith Brown's library, it was the translation from
    names to SIDs that was failing.

    Thanks for your suggestions Joe.

    John


    John Rusk Guest

  6. #5

    Default Re: Problems with IsInRole

    That's too bad. I've seen these kinds of problems, but they are pretty
    mysterious.

    You could also try using some Directory Services code to do this to overcome
    the issue with the LSA, but that will require more config and potentially be
    more brittle.

    Perhaps there is a way to solve the trust issue though. I'm the wrong guy
    to ask there, but I'm sure someone understands the options.

    Joe K.

    "John Rusk" <JohnRusk@discussions.microsoft.com> wrote in message
    news:AE2E348F-4FF9-444B-9B6B-B2E0A397C315@microsoft.com...
    >I think I've found the problem. I think its something like this:
    >
    > [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;262958[/url]
    >
    > While I'm not 100% sure that I'm suffering from _exactly_ the same
    > problem,
    > it seems that its possible to configure domain controllers in a way that
    > breaks .NET's role based security.
    >
    > I ended up dropping .NET's IsInRole, and using equivalent code from Keith
    > Brown's security library
    > ([url]http://www.theserverside.net/discussions/thread.tss?thread_id=25074[/url]).
    > That
    > was when I finally got the error 1789, which means "The trust relationship
    > between this workstation and the primary domain failed". It's a shame
    > that
    > .NET's IsInRole doesn't log anything to indicate what's going wrong. The
    > only sign was blank/missing names for global groups when I called
    > _GetRoles.
    >
    > In the code I used, from Keith Brown's library, it was the translation
    > from
    > names to SIDs that was failing.
    >
    > Thanks for your suggestions Joe.
    >
    > John
    >
    >

    Joe Kaplan \(MVP - ADSI\) 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