代码在我的本地计算机上运行良好但是当发布到服务器时它会在
上抛出DirectoryServiceCOMExceptionresults = mySearcher.FindAll();
代码行。 我的函数传递两个搜索框的内容,用户可以通过名称或位置查找员工:
// 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();
答案 0 :(得分:3)
可能的原因: