Get user groups

  • Thread starter Thread starter Alex Bibiano
  • Start date Start date
A

Alex Bibiano

I use this code to get the current user in my Windows application:

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity wi = WindowsIdentity.GetCurrent();
Console.WriteLine(wi.Name);


now, I want get the windows groups this users belong. How can I do it?

If I have to search in the ActiveDirectory, how can I know if the user is in
an ActiveDirectory Domain and his path?

A lot of thanks
 
Why do you need this, can't you simply use the IsInRole method to check
group membership?

Willy.
 
In the application I'm developing, when the application starts users can
select between different menus (menus are stored in a database). Every user
has access only to specific menus. I store also in the database for every
menu, the role (group) that can access to this menu (this role is an AD
group), and when the user start the application, I want populate a list whit
the menus user can access (only menus whit a group within user is). To do
this, I need a list of groups a user belongs.



Has somebody a better approach to do the same?



Alex Bibiano
 
Back
Top