为现有客户端应用程序配置OpenLDAP userCertificate

时间:2014-12-03 13:48:36

标签: c# .net windows ldap openldap

我是LDAP新手(大约1周)。我需要设置LDAP服务器,以便现有的客户端应用程序(遗憾的是我无法对其进行更改)可以从userCertificate属性读取证书。

问题是我只能在userCertificate;binary属性中存储证书,但客户端应用程序正在读取userCertificate属性,如下面的代码所示。

客户端应用程序是用C#编写的,这是它从LDAP服务器读取证书的方式:

using (DirectoryEntry entry = new DirectoryEntry("LDAP://[ldapAddress]"))
{
    entry.AuthenticationType = AuthenticationTypes.None;
    using (DirectorySearcher searcher = new DirectorySearcher())
    {
        searcher.SearchRoot = entry;
        searcher.Filter = "objectClass=inetOrgPerson";

        SearchResultCollection results = searcher.FindAll();

        foreach (SearchResult result in results)
        {
            byte[] buffer = new byte[0];
            if (result.Properties.Contains("userCertificate") && (result.Properties["userCertificate"] != null))
            {
                buffer = result.Properties["userCertificate"].Cast<byte[]>().First<byte[]>();
                X509Certificate2 certificate = new X509Certificate2(buffer);
            }
        }
    }
}

所以我想知道如何实现客户端应用程序可以从我的服务器读取证书?我正在使用OpenLDAP for Windows。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。现在我已经设置了一个与客户端应用程序一起使用的LDAP服务器。虽然我没有设法在OpenLDAP中执行此操作,但我安装了ApacheDS。 ApacheDS允许在没有userCertificate选项的;binary属性中存储证书。

当然,这并没有回答如何在OpenLDAP上做到这一点,但安装ApacheDS对我来说是足够好的解决方案。

当然,欢迎任何有关如何在OpenLDAP中实现这一目标的解决方案。

相关问题