how to sort generic collection of System.DirectoryServices.Principal objects RRS feed

  • Question

  • User-214059119 posted

    I have got a generic collection of System.DirectoryServices.Principal objects

     Dim results As PrincipalSearchResult(Of Principal)

    How do I sort it by DisplayName?

    Example or link would be greatly appreciated


    Tuesday, April 15, 2008 9:55 AM


  • User-691438185 posted


    Based on your post, my understanding of your problem is to fmake the filter in AccountManagement class by DisplayName. I would like to provide you the suggestions as follows:

    1. The AdvancedSearchFilter property returns object is set read-only properties before passing to the PrincipalSearcher. It is necessary to learn the query by example (QBE) search mechanism searches for objects in a directory using an existing object. To use QBE, the application creates an instance of a principal object, either computer, user, or group, and sets properties on the object. This object becomes the query filter for the PrincipalSearcher class. For futher information, please read the content of the link below:


    2. The Account Management API provides three concrete directory object classes: UserPrincipal, GroupPrincipal and ComputerPrincipal. Since the directory schema is modifiable, and not every attribute in the schema is represented by a property on these principal objects, developers may want to create their own custom principal objects. The Principal, AuthenticablePrincipal, UserPrincipal, ComputerPrincipal, and GroupPrincipal classes can all be extended to create custom objects that extend the object model. The article Principal Extensions provides you a releated example on extension issue.

    3. Additionally, I would like to introduce the article on managing the directory security principal issues that can help you to understand the issue further:

    Managing Directory Security Principals in the .NET Framework 3.5

    Hope that can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 17, 2008 2:57 AM