none
PrincipalContext Class does not work for a the global catalog. RRS feed

  • Question

  • The PrincipalContext Class works great when doing a lookup in a single domain, but fails in a forest of domains. Is there  a better class to use for the global catalog?

    Certified Geek

    Thursday, March 26, 2015 7:28 PM

Answers

  • The principalContext class throws an PrincipalOperationException when encountering a group with members from multiple domains in the forest.
    I think I can use the DirectorySearcher
    DirectoryEntry root = new DirectoryEntry("GC://dc=xxx,dc=com");
    DirectorySearcher searcher = new DirectorySearcher(root);
    searcher.Filter = string.Format("(&(objectCategory=group)(cn={0}))", mygroup);
    searcher.PropertiesToLoad.AddRange( new[] { "member" });
    The only problem is that my code needs to be recursive.

     


    Certified Geek

    • Marked as answer by Arne MN Wednesday, April 1, 2015 1:01 PM
    Tuesday, March 31, 2015 12:54 PM

All replies

  • Hello Arne,

    >> Is there  a better class to use for the global catalog?

    Please have a try to using the DirectorySearcher as described in this link when working against with a foreast.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 27, 2015 7:30 AM
    Moderator
  • That is some interesting code. I would like to search a group and find all the users. What would be the proper search filter?

    Certified Geek


    • Edited by Arne MN Friday, March 27, 2015 1:19 PM
    Friday, March 27, 2015 1:15 PM
  • Hello,

    >> I would like to search a group and find all the users. What would be the proper search filter?

    If you are trying to find all users in a group, the PrincipalContext Class you mentions in your original post could do this:

    http://stackoverflow.com/a/19604001

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, March 30, 2015 12:01 PM
    Moderator
  • The Principalcontext class fails when a group has members from different domains in the forrest. I need to find some code that can list all the members of a group that works for the global catalog. Principal context can do that a single domain.

    Certified Geek


    • Edited by Arne MN Monday, March 30, 2015 12:35 PM
    Monday, March 30, 2015 12:18 PM
  • Hello Arne,

    >>The Principalcontext class fails when a group has members from different domains in the forrest

    I am not quite sure what you mean "The Principalcontext class fails", does it throw an exception? If so, please share it with us. Or it means something else, please also tell us.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 31, 2015 12:42 PM
    Moderator
  • The principalContext class throws an PrincipalOperationException when encountering a group with members from multiple domains in the forest.
    I think I can use the DirectorySearcher
    DirectoryEntry root = new DirectoryEntry("GC://dc=xxx,dc=com");
    DirectorySearcher searcher = new DirectorySearcher(root);
    searcher.Filter = string.Format("(&(objectCategory=group)(cn={0}))", mygroup);
    searcher.PropertiesToLoad.AddRange( new[] { "member" });
    The only problem is that my code needs to be recursive.

     


    Certified Geek

    • Marked as answer by Arne MN Wednesday, April 1, 2015 1:01 PM
    Tuesday, March 31, 2015 12:54 PM