Solved

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

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now