The code works great on my local machine but when published to the server it throws the DirectoryServiceCOMException on the
results = mySearcher.FindAll();
line of the code.
My function passes the contents of two searchboxes where the user can lookup an employee by name or position:
// Bind to the users container.
string path = "LDAP://DC=DOMAIN,DC=TLD";
DirectoryEntry entry = new DirectoryEntry(path);
// Create a DirectorySearcher object.
DirectorySearcher mySearcher = new DirectorySearcher(entry);
// Set a filter for users with the name test.
mySearcher.Filter = "(&(objectClass=user)";
if (employeeName != "")
{
mySearcher.Filter = mySearcher.Filter + "(name=*" + employeeName + "*)";
}
if (position != "")
{
mySearcher.Filter = mySearcher.Filter + "(title=*" + position + "*)";
}
mySearcher.Filter = mySearcher.Filter + ")";
mySearcher.Sort = new SortOption("sn", System.DirectoryServices.SortDirection.Ascending);
// Use the FindAll method to return objects to a
// SearchResultCollection.
results = mySearcher.FindAll();
Possible reasons: