473,378 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Get user groups

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

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.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
Nov 16 '05 #1
2 10447
Why do you need this, can't you simply use the IsInRole method to check
group membership?

Willy.
"Alex Bibiano" <ab******@informatica.com> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
I use this code to get the current user in my Windows application:

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.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

Nov 16 '05 #2
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
"Willy Denoyette [MVP]" <wi*************@pandora.be> escribió en el mensaje
news:u0**************@tk2msftngp13.phx.gbl...
Why do you need this, can't you simply use the IsInRole method to check
group membership?

Willy.
"Alex Bibiano" <ab******@informatica.com> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
I use this code to get the current user in my Windows application:

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.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


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
0
by: Brian Loesgen | last post by:
The next San Diego .Net User Group meeting is Tuesday, November 25, 2003 at the Scripps Ranch Library. Scripps Ranch Library 10301 Scripps Lake Drive San Diego, CA 92131-1026 Please join us...
1
by: Access | last post by:
Here is my function to change a users permission level in the database. This relates to an Access database secured using Access security. This function is called if the end user changes a staff...
3
by: MLH | last post by:
I was running the following code while logged in as a user belonging only to the Users group. Set usrNew = .CreateUser(Me!UserID) 'The user ID is in a control on the form usrNew.PID =...
5
by: henrycortezwu | last post by:
Hi All, I'm trying to get the "groups" of a user that belongs to a domain by just passing the user's userID & domain. Is this possible? What I tried, and is working is the ff code ( i can get...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
1
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
8
by: Oliver Rainer | last post by:
Hi, I have the following problem... Pre-requisites: Installation of an Asp.net webservice on a IIS5 server (win2k). Anonymous access is not allowed, only using windows authentication (intranet...
4
by: PD | last post by:
Hello everyone, I had posted a question regarding how to design high traffic fast dating website on different PHP groups. I got a lot of useful responses. I have added links to all the posts...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.