码迷,mamicode.com
首页 > Windows程序 > 详细

c# DirectoryEntry LDAPS

时间:2019-12-26 19:27:22      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:when   serve   rap   director   cti   power   脚本   creat   set   

参考地址:
https://stackoverflow.com/questions/54987776/ldap-connection-error-the-server-is-not-operational-when-connecting-to-port

1. 测试 LDAPS 网络连接
Test-NetConnection ad.sipac.gov.cn -Port 636

2. 运行 power shell 下载证书的脚本(修改 $domain 参数值):
$domain = "ad.sipac.gov.cn"
$webRequest = [Net.WebRequest]::Create("https://$($domain):636")
try { $webRequest.GetResponse() } catch {}
$cert = $webRequest.ServicePoint.Certificate
$bytes = $cert.Export([Security.Cryptography.X509Certificates.X509ContentType]::Cert)
set-content -value $bytes -encoding byte -path "~\Downloads\$domain.cer"

3. 安装证书:
双击根证书文件,点击安装 -> 本地计算机 -> 将所有的证书都放入下列存储 -> 选择“受信任的根证书颁发机构” 点确定 -> 下一步

4. 代码中的 LDAP 连接字符串设置为 636 端口(LDAP 端口是 389,LDAPS 是 636)
"LDAP://ad.sipac.gov.cn:636/OU=bsyan,DC=sipac,DC=gov,DC=cn"

c# DirectoryEntry LDAPS

标签:when   serve   rap   director   cti   power   脚本   creat   set   

原文地址:https://www.cnblogs.com/myesn/p/DirectoryEntry-LDAPS.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!