DirectorySearcher & sorting

Discussion in 'ASP .Net' started by cameron, Jul 4, 2003.

  1. cameron

    cameron Guest

    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
    cameron, Jul 4, 2003
    #1
    1. Advertising

  2. cameron

    David Waz... Guest

    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]" <> wrote in message
    news:ex$...
    > This is not possible, Active Directory supports only a single sort key.
    >
    > Willy.
    >
    > "cameron" <> wrote in message

    news:...
    > > 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
    > >

    >
    >
    >
    David Waz..., Jul 4, 2003
    #2
    1. Advertising

  3. cameron

    cameron Guest

    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]" <> wrote in message
    > news:ex$...
    >
    >>This is not possible, Active Directory supports only a single sort key.
    >>
    >>Willy.
    >>
    >>"cameron" <> wrote in message

    >
    > news:...
    >
    >>>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
    >>>

    >>
    >>
    >>

    >
    >
    cameron, Jul 4, 2003
    #3
  4. 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: <>
    !Date: Fri, 04 Jul 2003 14:31:58 -0600
    !From: cameron <>
    !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: <>
    <ex$>
    <q4lNa.870$>
    !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.
    !>
    !>
    !>
    !> "Willy Denoyette [MVP]" <> wrote in message
    !> news:ex$...
    !>
    !>>This is not possible, Active Directory supports only a single sort key.
    !>>
    !>>Willy.
    !>>
    !>>"cameron" <> wrote in message
    !>
    !> news:...
    !>
    !>>>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
    !>>>
    !>>
    !>>
    !>>
    !>
    !>
    !
    !
    !
    Yan-Hong Huang[MSFT], Jul 7, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dave
    Replies:
    0
    Views:
    757
  2. Jay
    Replies:
    1
    Views:
    19,246
  3. =?Utf-8?B?QW5kcmV3MTI0?=

    DirectorySearcher.FindAll()

    =?Utf-8?B?QW5kcmV3MTI0?=, Jul 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,302
    =?Utf-8?B?QW5kcmV3MTI0?=
    Jul 11, 2004
  4. Roger Bavaud

    DirectorySearcher Filter Exchange Server

    Roger Bavaud, Nov 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    599
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 5, 2004
  5. cameron

    DirectorySearcher first access speed

    cameron, Nov 24, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    602
    Rhett Gong [MSFT]
    Nov 26, 2004
Loading...

Share This Page