Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-04-16
1
Medium Priority
?
561 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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