通过控制台应用程序使用端口636(安全)运行以下代码,它运行正常,但是通过ASP.Net网站失败:
DirectoryEntry authServer = new DirectoryEntry(@"LDAP://zxxx.cf.ac.uk:636", "", "", AuthenticationTypes.Anonymous);
DirectorySearcher directorySearch = new DirectorySearcher(authServer, "(CN=sissh6)");
SearchResult result = directorySearch.FindOne();
这是错误:
Problem authenticating : System.Runtime.InteropServices.COMException (0x8007203A):
The server is not operational.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne()
现在,如果我们使用非安全(没有端口636),那么问题就会消失,但最终解决方案必须是安全的。
为什么安全版本通过控制台应用程序工作,而不是通过asp.net?