DirectorySearcher - whats wrong with this?!


G

Guest

Hi

I'm getting the following error in my code...

"Exception Details: System.Runtime.InteropServices.COMException: The server
does not support the requested critical extension"

Here's the function...


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++;
}
}
finally {}

I *think* the problem is to do with the line

mySearcher.Sort = new SortOption("FirstName", SortDirection.Ascending);

Any help/ideas as to what's wrong appreciated!

Cheers


Dan
 
Ad

Advertisements

Ad

Advertisements

P

Pierre-Andre van Leeuwen

Are you sure that there is an attribute called FirstName in the user class?
It is usually called givenName
 

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

Top