Re: How to determine if the logged on user is in a group



Thanks Dominic, I think the problem is not in my code.
I saw that isinrole works with domains OK but I just found that
when I ran the whoami.exe /groups the custom groups that Bob belongs to on
the DC do not appear in his membership list
although he is a member of these groups. Only 15 groups appear when I run
Whoami, One custom group on the local workstation and all built-in groups on
the DC. I now think I have to find out why thed groups don't appear in the
workstation.
I just tested whoami for the same user on the DC and the custom groups I
created do not appear in the list there either.

By the way the MY is a new object in VB net 2005. You can use it with things
like MY.user It gives you the currently logged in user that is using your
app. My.appsettings lets you get application specific setting from the
config file etc..
Its easier than it was which is a good thing :-) But some things don't work
as advertised :-( oh well, what else is new :-)

If anyone can give me hint how to solve this thing I would really appreciate
it.

Bob



"Dominick Baier [DevelopMentor]" <dbaier@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in message news:4580be63182b6f8c7dad184c2a5c1@xxxxxxxxxxxxxxxxxxxxx
> Hi,
> don't know what My.. exactly does..
>
> but this works (i assume this is a desktop app)
>
> WindowsIdentity id = WindowsIdentity.GetCurrent();
> WindowsPrincipal p = new WindowsPrincipal(id);
>
> if (p.IsInRole(@"Domain\SomeGroup"))
> Console.WriteLine("You are member of some group");
>
> IsInRole works with domain accounts.
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>> Sorry if this is a bit of crosspost.
>> I'm using VS2005 and VB.net. I have a DC W2K that has a user group I
>> created, MyUsers, I put existing User Bob in that group.
>> I need in my VB app to determine if the currently logged on user is a
>> member of that group.
>>
>> I tried using my.user.isinrole("MyUsers") but I'm told that that only
>> looks at the local user groups, not the domain user groups. (not sure
>> if this is correct) because I gan get the domain name from my user, no
>> problem. In any case, to test that, I added a local user group to my
>> WinXp workstation MyUsers and put user Bob (the domain user account)
>> in the local MyUsers group.
>>
>> Still the code does not work. However when using built-in groups like
>> administrators the isinrole function works fine. So it seems there
>> must be a different way to find out if a user is part of a custom
>> group.
>>
>> Does anyone know of a bit of code that lets you verify if the
>> currently logged on user is a member of a group on a domain or on the
>> local computer?
>>
>> I'm at my wits end and I really would appreciate any help.
>>
>> Bob
>>
>
>


.



Relevant Pages

  • Re: How to determine if the logged on user is in a group
    ... I saw that isinrole works with domains OK but I just found that when I ran the whoami.exe /groups the custom groups that Bob belongs to on the DC do not appear in his membership list although he is a member of these groups. ... I tried using my.user.isinrolebut I'm told that that only looks at the local user groups, ...
    (microsoft.public.dotnet.security)
  • Re: IsinRole function only works with built-in roles
    ... I also looked at whoami /groups on my workstation and I notice that the custom groups that User Bob belongs to do not appear in the list. ... I tested the Isinrole on the Customone on the local machine by specifying the domain name and the local group in the isinrole and that works fine. ... If I create a new group on my domain controller then add an existing user to that group, user bob, group TestUsers and then try to determine if My.user.IsinroleI always get a false, which is incorrect. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: IsinRole function only works with built-in roles
    ... custom groups that User Bob belongs to do not appear in the list. ... I tested the Isinrole on the Customone on the local machine by specifying ... why does my custom groups that bob is a member do ... > on my domain controller then add an existing user to that group, user bob, ...
    (microsoft.public.dotnet.languages.vb)