Re: Check group member ship or a user

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 02/21/05


Date: Sun, 20 Feb 2005 19:10:03 -0600

Just out of curiosity, what version of .NET are you using? Early versions
of 1.0 had a bug where IsInRole was case sensitive.

The other thing I'd suggest is using reflection to troubleshoot the problem
by accessing the private _GetRoles method on WindowsIdentity. A quick
Google search should turn up some sample code that shows you how to do it.

http://groups-beta.google.com/group/microsoft.public.dotnet.security/msg/1f5ce5f46ae876a6

Joe K.

"Sameh Ahmed" <essoplus@hotmail.com> wrote in message
news:%23VHZgb6FFHA.2608@TK2MSFTNGP10.phx.gbl...
>I am on a local administrator on a stand alone machine, did not try it in a
>domain environment.
> how do you format the group name in your code?
> Regards
> Sameh
> "DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message
> news:O09AWM6FFHA.348@TK2MSFTNGP09.phx.gbl...
>>I have only gotten IsInRole to work against local groups when I have been
>>logged in as a local machine user, rather than as a domain user. I don't
>>know if that is by design or a bug (feature).
>>
>> HTH
>>
>> DalePres
>>
>>
>> "Sameh Ahmed" <essoplus@hotmail.com> wrote in message
>> news:%23R2j5M5FFHA.3664@TK2MSFTNGP15.phx.gbl...
>>> Well I use IsInRole to check windows built-in Roles
>>> what I want to do is to check if the current principal is a member of a
>>> local group called "Mygroup" for example.
>>> below is what I got from the MSDN
>>> [Visual Basic]
>>> Overloads Public Overridable Function IsInRole( _
>>> ByVal role As String _
>>> ) As Boolean Implements IPrincipal.IsInRole
>>>
>>> I tried "machinename\groupname", "groupname" and it returns False all
>>> the time.
>>> what am I missing here?
>>> Regards and thanks for your time
>>> Sameh
>>>
>>>
>>> "DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message
>>> news:e2514S1FFHA.3664@TK2MSFTNGP15.phx.gbl...
>>>> Look up the IPrincipal.IsInRole() method. You would use the
>>>> WindowsPrincipal implementation for WindowsForms or the User.IsInRole()
>>>> implementation for WebForms.
>>>>
>>>> DalePres
>>>> MCAD, MCDBA, MCSE
>>>>
>>>> "Sameh Ahmed" <essoplus@hotmail.com> wrote in message
>>>> news:ujomq3zFFHA.2736@TK2MSFTNGP09.phx.gbl...
>>>>> Hello there
>>>>> Is there a way through dotNet to check if a certain user is a member
>>>>> of a specific group?
>>>>> I use ADSI to get the memberships of the user then compare them to the
>>>>> group I want to check, but this way the user has to be a member of
>>>>> this group directly and if he is a member of a group that is a member
>>>>> of that group he will not be considered a member of the group I am
>>>>> checking although he is implicitly.
>>>>> so basically what I need is a method that takes the user name and the
>>>>> group name and check if this user is a member both implicitly or
>>>>> explicitly.
>>>>> Any ideas?
>>>>> Regards
>>>>> Sameh
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Relevant Pages

  • Re: Check group member ship or a user
    ... of 1.0 had a bug where IsInRole was case sensitive. ... >>I have only gotten IsInRole to work against local groups when I have been ... >>logged in as a local machine user, rather than as a domain user. ...
    (microsoft.public.dotnet.security)
  • Re: Check group member ship or a user
    ... On my machine, with the code above, both IsInRole calls return true. ... >domain environment. ... >>I have only gotten IsInRole to work against local groups when I have been ... >>logged in as a local machine user, rather than as a domain user. ...
    (microsoft.public.dotnet.security)
  • Re: Check group member ship or a user
    ... On my machine, with the code above, both IsInRole calls return true. ... >domain environment. ... >>I have only gotten IsInRole to work against local groups when I have been ... >>logged in as a local machine user, rather than as a domain user. ...
    (microsoft.public.dotnet.languages.vb)
  • User.IsInRole() fails if user in too many groups?
    ... My IsInRole() checks return false for ALL membership checks if a given ... watched results change after I incrementally added a domain user to ... user is in XX local groups. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Check group member ship or a user
    ... I have only gotten IsInRole to work against local groups when I have been ... logged in as a local machine user, rather than as a domain user. ... > Well I use IsInRole to check windows built-in Roles ... >> WindowsPrincipal implementation for WindowsForms or the User.IsInRole ...
    (microsoft.public.dotnet.security)