Get user groups

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
 
W

Willy Denoyette [MVP]

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

Willy.
 
A

Alejandro Bibiano González

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top