By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,543 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,543 IT Pros & Developers. It's quick & easy.

DirectorySearcher & sorting

P: n/a
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

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

"Willy Denoyette [MVP]" <wi*************@skynet.be> wrote in message
news:ex*************@TK2MSFTNGP10.phx.gbl...
This is not possible, Active Directory supports only a single sort key.

Willy.

"cameron" <ca****************@appdepot.com> wrote in message

news:3F**************@appdepot.com...
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


Nov 13 '05 #2

P: n/a
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.

"Willy Denoyette [MVP]" <wi*************@skynet.be> wrote in message
news:ex*************@TK2MSFTNGP10.phx.gbl...
This is not possible, Active Directory supports only a single sort key.

Willy.

"cameron" <ca****************@appdepot.com> wrote in message


news:3F**************@appdepot.com...
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



Nov 13 '05 #3

P: n/a
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: <3F**************@appdepot.com>
!Date: Fri, 04 Jul 2003 14:31:58 -0600
!From: cameron <ca****************@appdepot.com>
!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: <3F**************@appdepot.com>
<ex*************@TK2MSFTNGP10.phx.gbl>
<q4***************@newssvr23.news.prodigy.com>
!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!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:32353
microsoft.public.dotnet.languages.csharp:30649
!X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
!
!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.
!>
!>
!>
!> "Willy Denoyette [MVP]" <wi*************@skynet.be> wrote in message
!> news:ex*************@TK2MSFTNGP10.phx.gbl...
!>
!>>This is not possible, Active Directory supports only a single sort key.
!>>
!>>Willy.
!>>
!>>"cameron" <ca****************@appdepot.com> wrote in message
!>
!> news:3F**************@appdepot.com...
!>
!>>>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
!>>>
!>>
!>>
!>>
!>
!>
!
!
!

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.