C# 目录搜索程序异常
我已经为搜索目录编写了以下代码,但是C# 目录搜索程序异常,c#,.net,C#,.net,我已经为搜索目录编写了以下代码,但是Searcher.FindOne()我收到异常[未知错误(0x80005000)] 您正在捕获所有有价值的异常并将其丢弃。尝试捕获并记录异常。这就是您从异常对象获得的全部信息吗?(哪个应该在catch(Exception ex))域的值是多少?另外:您应该捕获异常(catch(exception ex)),然后检查异常的内容-它告诉您什么(详细信息,包括所有.InnerException详细信息)? bool Success = false; System.
Searcher.FindOne()代码>我收到异常[未知错误(0x80005000)]
您正在捕获所有有价值的异常并将其丢弃。尝试捕获并记录异常。这就是您从异常对象获得的全部信息吗?(哪个应该在catch(Exception ex)
)域的值是多少?另外:您应该捕获异常(catch(exception ex)
),然后检查异常的内容-它告诉您什么(详细信息,包括所有.InnerException
详细信息)?
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;