Solved

Using Directory Searcher to FindAll GroupPrincipal objects that have a certain description

Posted on 2014-04-16
1
540 Views
Last Modified: 2014-04-17
I'm basically trying to figure out if I can (and if so how) use the PrincipalSearcher object in .net to find all GroupPrincipal objects that have a description property matching a certain value...

For Example lets say I have a GroupPrincipal object for the AD Group abc123  and its description property if Group_Alpha_One...

Well what if I want to find any and all groups with he description value for the Group Principal of "Group_Alpha_One"
0
Comment
Question by:Bastyon
1 Comment
 

Accepted Solution

by:
Bastyon earned 0 total points
ID: 40007000
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "US");
            GroupPrincipal grp = new GroupPrincipal(ctx);
            grp.Description = "description value";
            PrincipalSearcher ps = new PrincipalSearcher(grp);
            ps.QueryFilter = grp;
            PrincipalSearchResult<Principal> result = ps.FindAll();
            int i = 0;
            List<string> s = new List<string>();
            foreach (Principal p in result)
            {
                using (GroupPrincipal gp = (GroupPrincipal)p)
                {
                    s.Add(gp.Name);
                }
            }
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question