DirectorySearcher & sorting

C

cameron

I would like to do a search and have the results sorted by property 1
and then by property 2. My first thought had been

//set up the searching object and call it oSearch
oSearch.Sort.PropertyName = "Property1,Proptery2";

but that was unhappy. I can do a
oSearch.Sort.PropertyName = "Property1";
or
oSearch.Sort.PropertyName = "Property2";
without issue but I can not figure out how to do what I need. I took a
look at the System.DirectoryServices.SortOption and it doesn't seem to
do anything new either. I am dealing with a fairly large result set so I
REALLY do not want to have to do a sort myself after I get the results.

Thanks.

-Cam
 
D

David Waz...

If you move the content into a DataTable, your first method would work.
o_Table.DefaultView.SortExpression="Prop1, Prop2"

Then use the datatable as the source of your data.
 
C

cameron

Move the content? Copy the actual data from AD to a SQL table? Wouldn't
that be nasty expensive to do whenever I needed to search? Or is there a
way to access the underlaying Database object?

-Cam
 
Y

Yan-Hong Huang[MSFT]

Hello Cam,

There is no need to copy all the AD data to SQL table? What we need to do
is to see whether it is possible to copy the search result into a dataset.

Please refer to http://www.dotnet247.com/247reference/msgs/1/9450.aspx.
Hope it helps.

Best regards,
yhhuang
VS.NET, Visual C++
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
!Message-ID: <[email protected]>
!Date: Fri, 04 Jul 2003 14:31:58 -0600
!From: cameron <[email protected]>
!User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0)
Gecko/20020530
!X-Accept-Language: en-us, en
!MIME-Version: 1.0
!Subject: Re: DirectorySearcher & sorting
!References: <[email protected]>
<[email protected]>
<[email protected]>
!Content-Type: text/plain; charset=us-ascii; format=flowed
!Content-Transfer-Encoding: 7bit
!Newsgroups:
microsoft.public.dotnet.languages.csharp,microsoft.public.dotnet.framework.a
spnet
!NNTP-Posting-Host: hssxrg64-201-211-159.sasknet.sk.ca 64.201.211.159
!Lines: 1
!Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:32353
microsoft.public.dotnet.languages.csharp:30649
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Move the content? Copy the actual data from AD to a SQL table? Wouldn't
!that be nasty expensive to do whenever I needed to search? Or is there a
!way to access the underlaying Database object?
!
!-Cam
!
!David Waz... wrote:
!> If you move the content into a DataTable, your first method would work.
!> o_Table.DefaultView.SortExpression="Prop1, Prop2"
!>
!> Then use the datatable as the source of your data.
!>
!>
!>
!> !>
!>>This is not possible, Active Directory supports only a single sort key.
!>>
!>>Willy.
!>>
!>
!> !>
!>>>I would like to do a search and have the results sorted by property 1
!>>>and then by property 2. My first thought had been
!>>>
!>>>//set up the searching object and call it oSearch
!>>>oSearch.Sort.PropertyName = "Property1,Proptery2";
!>>>
!>>>but that was unhappy. I can do a
!>>>oSearch.Sort.PropertyName = "Property1";
!>>>or
!>>>oSearch.Sort.PropertyName = "Property2";
!>>>without issue but I can not figure out how to do what I need. I took a
!>>>look at the System.DirectoryServices.SortOption and it doesn't seem to
!>>>do anything new either. I am dealing with a fairly large result set so I
!>>>REALLY do not want to have to do a sort myself after I get the results.
!>>>
!>>>Thanks.
!>>>
!>>>-Cam
!>>>
!>>
!>>
!>>
!>
!>
!
!
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top