Solved

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

Posted on 2014-04-16
1
535 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to Decrypt in C# a string that is encrypted with Coldfusion Encrypt(string, seed) function 11 100
Connection String 16 54
VB: Convert 2 dates to specific format 24 48
Hey!!!! 1 20
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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