【发布时间】:2021-10-06 21:34:59
【问题描述】:
我正在尝试使用 .NET 对象执行与 LDAP 实例的绑定。 抱歉,这是我第一次与这种敌人作战(希望也是最后一次!)。
这是我实际做的:
LdapDirectoryIdentifier serverId = new LdapDirectoryIdentifier(primaryIP, securePort);
NetworkCredential credentials = new NetworkCredential(username, password);
using (LdapConnection conn = new LdapConnection(serverId, credentials))
{
try
{
//conn.SessionOptions.ProtocolVersion = 3;
conn.SessionOptions.SecureSocketLayer = true;
conn.AuthType = (AuthType)authType;
conn.Bind();
Console.WriteLine("OK!!");
}
catch (LdapException lex)
{
Console.WriteLine($"Errore {lex.ErrorCode}: {lex.Message}");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
地点:
- primaryIP 是 LDAP 实例的名称
- securePort 是 636
- 用户名和密码绝对正确(我已经检查他们登录到内网)
我找到了很多例子,一切看起来都非常简单明了。反正我过不去。 还尝试了所有可用的 AuthTypes,但没有运气。 如前所述,用户存在是因为我能够登录到使用这种身份验证的不同应用程序。
【问题讨论】: