【发布时间】:2009-08-04 17:54:32
【问题描述】:
我正在进行的项目将与客户的 Active Directory 集成,以便对用户进行身份验证。我一直在尝试编写一些代码来检索用户密码,并且我知道 Active Directory 只会通过端口 636 上的 SSL 连接公开相关属性。
以下代码在不使用 SSL 的情况下以编程方式连接,但我看不到密码属性:
static void Main(string[] args)
{
DirectoryEntry entry = new DirectoryEntry(@"LDAP://<IP>/CN=LDAP Test,CN=Users,DC=customer,DC=com");
entry.AuthenticationType = AuthenticationTypes.None;
entry.Username = "CN=LDAP Test,CN=Users,DC=customer,DC=com";
entry.Password = "<password>";
if (entry != null)
{
foreach (Object propName in entry.Properties.PropertyNames)
{
Console.WriteLine((String)propName);
}
}
}
当我将代码更改为使用 SSL 时,我收到一个异常声明:未知错误 (0x80005000)'。
我在托管 Active Directory 的服务器上启用了 SSL,在同一台服务器上安装了 Microsoft CA,并从 CA 获得了证书。
我可以使用 Apache Directory Studio 通过 SSL 连接到 Active Directory,但不显示密码属性。
以下代码显示了我一直在尝试使用 SSL 进行连接:
static void Main(string[] args)
{
DirectoryEntry entry = new DirectoryEntry(@"LDAPS://<IP>:636/CN=LDAP Test,CN=Users,DC=customer,DC=com");
entry.AuthenticationType = AuthenticationTypes.SecureSocketsLayer;
entry.Username = "CN=LDAP Test,CN=Users,DC=customer,DC=com";
entry.Password = "<password>";
if (entry != null)
{
foreach (Object propName in entry.Properties.PropertyNames)
{
Console.WriteLine((String)propName);
}
}
}
我不知道该怎么做,我们将不胜感激。
【问题讨论】:
-
ADAM 常见问题解答在这里:microsoft.com/windowsserver2003/adam/ADAMfaq.mspx#EOD
-
这个问题的标题具有误导性,应该类似于“如何从 Active Directory 中检索用户密码?”它与“启用 SSL 连接到 Active Directory?”无关?
标签: c# ssl active-directory