【发布时间】:2021-12-02 10:37:18
【问题描述】:
private void ADQuery()
{
try
{
string connString = "LDAP://10.0.10.11/dc=abcd,dc=ac,dc=in";//demo url
string username = "cn=admin,dc=abcd,dc=ac,dc=in";
string name = "cn=admin,dc=abcd,dc=ac,dc=in";
string password = "secrate";
string name2 = "10.0.10.11\admin";// domain\username
DirectoryEntry de = new DirectoryEntry(connString, name2, "secrate", AuthenticationTypes.Secure);
var search = new DirectorySearcher(de)
{
Filter = "(&(ou=employee)(objectClass=inetOrgPerson))"
};
search.SearchScope = SearchScope.Subtree;
// error thrown by this statement
SearchResult results = search.FindOne();
if (results != null)
{
string email = results.Properties["mail"].ToString();
}
}
catch (Exception ex)
{
throw ex;
}
}
我收到此错误:
“/”应用程序中的服务器错误。
发生了本地错误。
说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详情:
System.DirectoryServices.DirectoryServicesCOMException:发生本地错误
【问题讨论】:
标签: c# asp.net active-directory ldap