Sort the collection by the values of named attributes. Sort direction is ascending.
[Visual Basic] MustOverride OverloadsPublic Sub SortBy( _ ByVal attributeName As String _ ) [C#] public abstract void SortBy( string attributeName ); [C++] public: abstract void SortBy( String* attributeName ); [JScript] public abstract function SortBy( String attributeName );
[C#] using System;
using LdapServices.Ldap;
namespace LDAPSampleCodeConsole
{
class SampleApp
{
static void Main(string[] args)
{
Client client = new Client();
// Connect to the directory
client.Connect("directory.yourServer.ca");
// Search the directory for entries with surname starting with 'Ab'
EntryCollection entries;
entries = client.Search("o=yourCompany,c=ca", "sn=Ab*");
// Sort the entries by surname in alphabetical order
entries.SortBy("sn");
foreach (Entry entry in entries)
{
Console.WriteLine("Surname: " + entry.Attributes["sn"].Values[0].StringValue + " dn: " + entry.DN);
}
// Disconnect
client.Disconnect();
}
}
}
EntryCollection Class | LdapServices.Ldap Namespace | EntryCollection.SortBy Overload List