Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用SSL与Active Directory联系_C#_Ssl_Active Directory_Dmz - Fatal编程技术网

C# 使用SSL与Active Directory联系

C# 使用SSL与Active Directory联系,c#,ssl,active-directory,dmz,C#,Ssl,Active Directory,Dmz,我有一个根据Active Directory验证用户凭据的方法。我想将此方法用于SSL,但无法使其工作 主要的问题是,我有一个服务器在我们的网络之外,它叫DMZ吗?。从那里我想联系我的active directory,这就是为什么我想使用SSL 在我的本地计算机(非DMZ)上使用时,我收到以下错误: System.DirectoryServices.AccountManagement.PrincipalServerDownException:无法联系服务器。-->System.Directory

我有一个根据Active Directory验证用户凭据的方法。我想将此方法用于SSL,但无法使其工作

主要的问题是,我有一个服务器在我们的网络之外,它叫DMZ吗?。从那里我想联系我的active directory,这就是为什么我想使用SSL

在我的本地计算机(非DMZ)上使用时,我收到以下错误:

System.DirectoryServices.AccountManagement.PrincipalServerDownException:无法联系服务器。-->System.DirectoryServices.Protocols.LdapException:LDAP服务器不可用。 位于System.DirectoryServices.Protocols.LdapConnection.Connect 在System.DirectoryServices.Protocols.LdapConnection.SendRequestHelperDirectoryRequest请求中,Int32&messageID 在System.DirectoryServices.Protocols.LdapConnection.SendRequestDirectoryRequest请求中,TimeSpan requestTimeout 位于System.DirectoryServices.Protocols.LdapConnection.SendRequestDirectoryRequest 位于System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfigString服务器名称、服务器属性和属性

--内部异常堆栈跟踪的结束-- 位于System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfigString服务器名称、服务器属性和属性 位于System.DirectoryServices.AccountManagement.PrincipalContext.DoServer验证和PropRetrieval 位于System.DirectoryServices.AccountManagement.PrincipalContext..ctorContextType contextType,字符串名称,字符串容器,ContextOptions选项,字符串用户名,字符串密码 位于System.DirectoryServices.AccountManagement.PrincipalContext..ctorContextType contextType,字符串名称,字符串容器,ContextOptions选项 在Authorization.AuthorizeAD.ValidateCredentialsString用户名、字符串密码处

我想在我从我们的服务器上尝试之前,最好先从本地使用SSL

我的方法:

public bool ValidateCredentials(string username, string password) {
        using (
            var context = new PrincipalContext(ContextType.Domain, ContextName, ContextContainer,
                ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing |
                ContextOptions.SecureSocketLayer)) {
            return context.ValidateCredentials(username, password);
        }
    }
如前所述,如果不使用ContextOptions.SecureSocketLayer,则可以正常工作。如果参数为null,则默认情况下,其他三个参数为空


有人知道我应该如何将PrincipalContext与SSL一起正确使用吗?

您确定它支持SSL并且防火墙已打开以允许该连接吗

LDAP使用端口389。LDAPS使用端口636

如果已安装telnet客户端,则可以使用它检查连接:

telnet yourdomain.com 636
如果你得到一个空白屏幕,它就工作了。如果无法连接,它会告诉你

如果这是开放的,但仍然不起作用,则可能是使用自签名SSL证书。检查Windows事件日志中与证书相关的错误

我还使用了Chrome来检查证书。您必须像这样运行chrome:

chrome.exe --explicitly-allowed-ports=636

然后浏览到https://yourdomain.com:636 并查看它是否给您任何证书错误。然后你就可以看到证书了。如果是这个问题,您可以导入证书并显式信任它。

您确定它支持SSL并且防火墙已打开以允许该连接吗

LDAP使用端口389。LDAPS使用端口636

如果已安装telnet客户端,则可以使用它检查连接:

telnet yourdomain.com 636
如果你得到一个空白屏幕,它就工作了。如果无法连接,它会告诉你

如果这是开放的,但仍然不起作用,则可能是使用自签名SSL证书。检查Windows事件日志中与证书相关的错误

我还使用了Chrome来检查证书。您必须像这样运行chrome:

chrome.exe --explicitly-allowed-ports=636

然后浏览到https://yourdomain.com:636 并查看它是否给您任何证书错误。然后你就可以看到证书了。如果是这个问题,您可以导入证书并显式信任它。

那么PrincipalContext类为此使用LDAP协议吗?它必须。LDAP是用于与Active Directory通信的唯一协议。更多细节:PrincipalContext类为此使用LDAP协议吗?它必须。LDAP是用于与Active Directory通信的唯一协议。更多详情: