目录搜索器例外

时间:2013-09-26 07:34:38

标签: c# .net

我已经编写了以下代码来搜索目录,但Searcher.FindOne();我得到了异常[Unknown error (0x80005000)]

bool Success = false;

System.DirectoryServices.DirectoryEntry Entry = 
   new System.DirectoryServices.DirectoryEntry("LDAP://" + Domain, Username, Password);

System.DirectoryServices.DirectorySearcher Searcher = 
   new System.DirectoryServices.DirectorySearcher(Entry);

Searcher.SearchScope = System.DirectoryServices.SearchScope.OneLevel;
try
{
     System.DirectoryServices.SearchResult Results = Searcher.FindOne();
     Success = (Results != null);
}
catch
{
     Success = false;
}
return Success;

0 个答案:

没有答案