Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2004

Tip: Looking for answers? Try searching our database.

Directory Searcher Multi-Sort

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe Mack - 25 Oct 2004 19:39 GMT
I am a newbie to .NET.  I am coding a web part for SPS that returns all of
the users from an Active Directory tree, sorted by attribute x (in this case,
Company).  This works fine.

How can I sort the results within each company by a separate criterion
(e.g., alphabetically by last name).  I am sure that I could do this by
building myself a multi-dimensional array from the objects in my
searchresultcollection prior to rendering the information in my web part, but
I would think there is an easier way.

Can you perform a sort on multiple attributes using the DirectorySearcher
object?  If so, where can I find an example of the syntax to accomplish this?

Thanks in advance.

Joe
Marc Scheuner [MVP ADSI] - 26 Oct 2004 10:51 GMT
>Can you perform a sort on multiple attributes using the DirectorySearcher
>object?  If so, where can I find an example of the syntax to accomplish this?

No, you cannot per se - out of the box. However, what you CAN do, is
stash your results (e.g. the list of objects of type "SearchResult")
into a collection, and apply a custom sorter to that collection.

Read up on collections (esp. ArrayList) and custom comparers in your
MSDN docs - you can basically write your own little class that
compares two of your objects (whatever they might be), and determines
whichever of the two is comes first. This can be used by the basic
.Sort method on the ArrayList to sort your objects in any order you
might want them to be sorted in.

Marc

================================================================
Marc Scheuner                        May The Source Be With You!
Bern, Switzerland                         m.scheuner(at)inova.ch

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.