我正在尝试将PrincipalContext用于我正在开发的use服务。我已经在web服务器上的另一个应用程序中使用了表单身份验证,它工作得很好。
我收到的错误是:
System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server could not be contacted. ---> System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.
at System.DirectoryServices.Protocols.LdapConnection.Connect()
at System.DirectoryServices.Protocols.LdapConnection.SendRequestHelper(DirectoryRequest request, Int32& messageID)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, String userName, String password)
at webService.Service1.ValidUser(String sUserName) in E:\Development\CSharpApps\Desktop\OrgChart\webService\Service1.asmx.cs:line 158
我们的DMZ服务器位于DMZ中,通过防火墙访问该域。我使用下面的端口信息等作为示例。
这是使用我的开发箱中的ip来工作的,但是它在防火墙内。我发送给它的ip信息与我在web forms身份验证中使用的信息相同。
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "192.168.1.1:389", "dc=doodlie,dc=com",@"doodlie\admin","doodliesquat");
发布于 2016-11-10 02:15:13
也许我漏掉了什么,但您实际上不必指定AD服务器,您可以简单地说:
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
并且它应该在应用程序的当前域中找到它能找到的任何DC。如果它是一个具有容错能力的网络,当一个网络出现故障时,另一个应该会恢复。我不确定为什么会有理由点击一个,特别是,像原始问题中的代码那样,除非它在不同的域上。如果是这种情况,您可以尝试在该域上托管您的web服务,并使用DNS和转发器调用/路由到新域上的web服务的新IP (如果需要),或者使用主机文件条目,或者仅通过IP引用web服务。
发布于 2014-04-29 06:56:09
不管是什么问题,安装其中一些用于AD管理/故障排除的无价工具对我来说是上天的恩赐。
如果可能,在您的计算机/或web服务器(如果允许)上安装远程服务器管理工具(RSAT),然后使用Active Directory用户和计算机客户端确定DC的确切URL/ip。如果您无法使用这些工具进行连接,这可能是升级到IT支持/开发运营的起点
除此之外,运行网站应用程序的AD/service帐户可能没有足够的权限访问DC。我已经取得了成功,
using (HostingEnvironment.Impersonate())
{
// code in here.
}
在IIS中运行网站应用程序的应用程序池应在具有适当权限的用户帐户下运行。(不一定只是网络服务)
发布于 2015-06-22 17:50:04
在我的例子中,从url中删除端口号是可行的。
https://stackoverflow.com/questions/7572808
复制相似问题