Solved

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

Posted on 2014-04-16
1
555 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 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