我们已经使用了一段时间的应用程序,它使用System.DirectoryServices.AccountManagement与活动目录(域上下文)通信。
ContextOptions options = ContextOptions.Negotiate |
ContextOptions.SecureSocketLayer;
Using(PrincipalContext adContext = new PrincipalContext(ContextType.Domain, "AD.DOMAIN", "DC=AD,DC=intranet", options))
{
//Do stuff
}在插入智能卡之前,这个功能很好。当我们插入带有用户证书的智能卡时,一旦它到达PrincipalContext构造函数,它就会提示输入智能卡引脚。取消时,应用程序将崩溃。当输入正确的引脚时,它只会一遍又一遍地提示。
它似乎链接到在后台设置的TLS会话。当我们不启用加密时,这个问题就不存在了。但加密是强制性的。
以前有人遇到过这个问题吗?资源似乎有限。我能找到的最接近的是:
提前感谢
发布于 2018-05-03 13:53:51
PrincipalContext利用内部类CredentialValidator在LDAP绑定期间进行身份验证。
private bool BindLdap(NetworkCredential creds, ContextOptions contextOptions)
{
LdapConnection current = (LdapConnection) null;
...
current = new LdapConnection(this.directoryIdent);
...
try
{
current.SessionOptions.FastConcurrentBind();FastConcurrentBind方法查找证书,并在它请求PIN的连接选项中启用SSL。
如果不支持快速绑定,则调用Bind并执行相同的操作:
private void lockedLdapBind(
LdapConnection current,
NetworkCredential creds,
ContextOptions contextOptions)
{
current.AuthType =
(ContextOptions.SimpleBind & contextOptions) > (ContextOptions) 0
? AuthType.Basic
: AuthType.Negotiate;
current.SessionOptions.Signing =
(ContextOptions.Signing & contextOptions) > (ContextOptions) 0;
current.SessionOptions.Sealing =
(ContextOptions.Sealing & contextOptions) > (ContextOptions) 0;
if (creds.UserName == null && creds.Password == null)
current.Bind();
else
current.Bind(creds);
}为了防止出现这种情况,必须像这样修改会话选项
current.SessionOptions.QueryClientCertificate =
new QueryClientCertificateCallback((a,b) => null);问题是,不能从外部对内部类执行此操作。
只能在手动构造LdapConnection对象.时才能完成。
https://stackoverflow.com/questions/47160786
复制相似问题