G
Guest
Hi peeps,
I had a function working fine for retrieving a list of users from Active
Directory. However, client wants it sorted alphabetically. So I added Sort
option to my searcher, and now the code won't run... perhaps someone can tell
me whats up with it, and more importantly how to fix it...
Here's the code...
private void PullADUsers()
{
int listc;
string cs;
DirectoryEntry entry = new DirectoryEntry("LDAP://" +
ConfigurationSettings.AppSettings.Get("System_ActiveDirPath"));
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=user)");
mySearcher.Sort = new SortOption("FirstName", SortDirection.Ascending);
listc = 1;
foreach(SearchResult resEnt in mySearcher.FindAll())
{
try
{
DirectoryEntry de = resEnt.GetDirectoryEntry();
if((de.Properties["DisplayName"].Value != null) &&
(de.Properties["givenName"].Value != null) && (de.Properties["sn"].Value !=
null))
{
ListItem adItem = new ListItem();
adItem.Text = de.Properties["givenName"].Value.ToString() + " " +
de.Properties["sn"].Value.ToString();
adItem.Value = de.Properties["sAMaccountname"].Value.ToString();
ddlDartsContact.Items.Insert(listc, adItem);
adItem = null;
listc++;
}
}
catch
{
// my catch code here
}
finally {}
}
}
The error I'm getting is...
Exception Details: System.Runtime.InteropServices.COMException: The server
does not support the requested critical extension
....and occours on the for() line.
Hope someone can help!
Cheers
Dan
I had a function working fine for retrieving a list of users from Active
Directory. However, client wants it sorted alphabetically. So I added Sort
option to my searcher, and now the code won't run... perhaps someone can tell
me whats up with it, and more importantly how to fix it...
Here's the code...
private void PullADUsers()
{
int listc;
string cs;
DirectoryEntry entry = new DirectoryEntry("LDAP://" +
ConfigurationSettings.AppSettings.Get("System_ActiveDirPath"));
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=user)");
mySearcher.Sort = new SortOption("FirstName", SortDirection.Ascending);
listc = 1;
foreach(SearchResult resEnt in mySearcher.FindAll())
{
try
{
DirectoryEntry de = resEnt.GetDirectoryEntry();
if((de.Properties["DisplayName"].Value != null) &&
(de.Properties["givenName"].Value != null) && (de.Properties["sn"].Value !=
null))
{
ListItem adItem = new ListItem();
adItem.Text = de.Properties["givenName"].Value.ToString() + " " +
de.Properties["sn"].Value.ToString();
adItem.Value = de.Properties["sAMaccountname"].Value.ToString();
ddlDartsContact.Items.Insert(listc, adItem);
adItem = null;
listc++;
}
}
catch
{
// my catch code here
}
finally {}
}
}
The error I'm getting is...
Exception Details: System.Runtime.InteropServices.COMException: The server
does not support the requested critical extension
....and occours on the for() line.
Hope someone can help!
Cheers
Dan