Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2007

Tip: Looking for answers? Try searching our database.

A list of people in an active directory group.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
newscorrespondent@charter.net - 09 Jul 2007 23:55 GMT
I am using System.Security.Principal to identify clients and allow
functionality based on the groups they belong to. In one case I would like
to let them know who can do the function they cannot. How do I list the
members of a group?

Thanks
Tom
Nick - 11 Jul 2007 19:53 GMT
http://www.codeproject.com/dotnet/QueryADwithDotNet.asp

Let's get a list of users belonging to a particular AD group. The code below
shows how to do this:

ArrayList GetADGroupUsers(string groupName)
{    SearchResult result;
   DirectorySearcher search = new DirectorySearcher();
   search.Filter = String.Format("(cn={0})", groupName);
   search.PropertiesToLoad.Add("member");
   result = search.FindOne();

   ArrayList userNames = new ArrayList();
   if (result != null)
   {
       for (int counter = 0; counter <
                result.Properties["member"].Count; counter++)
       {
           string user = (string)result.Properties["member"][counter];
           userNames.Add(user);
       }
   }
   return userNames;
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.