【发布时间】:2020-09-28 23:18:25
【问题描述】:
我们的域控制器上运行着 Active Directory,另一台服务器上运行着 IIS。我正在开发一个需要查询 AD 的网络应用程序。
页面加载代码在最后一行失败:
string Iam;
string myLDAP;
DirectoryEntry de = new DirectoryEntry("LDAP://RootDSE");
myLDAP = "LDAP://" + de.Properties["defaultNamingContext"][0].ToString();
TextBox1.Text = "Retrieving your security details.....";
Iam = HttpContext.Current.User.Identity.Name;
TextBox1.Text += " " + Iam + " " + myLDAP;
DirectorySearcher ds = new DirectorySearcher(de);
ds.Filter = "(&(objectCategory=user)(objectClass=person))";
SearchResultCollection result = ds.FindAll();
我收到此错误:
[NotSupportedException: 提供程序不支持搜索,无法搜索 LDAP://RootDSE。]
显然,我对在多台服务器上使用 LDAP 的理解有所欠缺,感谢您的帮助。
【问题讨论】:
-
Windows 不允许用户名/密码。您需要使用凭据。使用用户名/密码信息未加密。使用凭据,用户名/密码不会在未加密的情况下发送。
-
你是在本地遇到这个错误,还是只在iis中遇到这个错误?
-
本地没试过;我正在远程工作,而不是在域中。
标签: c# iis active-directory ldap