C# 为现有客户端应用程序配置OpenLDAP用户证书

C# 为现有客户端应用程序配置OpenLDAP用户证书,c#,.net,windows,ldap,openldap,C#,.net,Windows,Ldap,Openldap,我是LDAP新手(大约1周)。我需要设置LDAP服务器,以便现有的客户端应用程序(不幸的是,我无法对其进行更改)可以从userCertificate属性读取证书 问题是我只能在userCertificate中存储证书;二进制属性,但客户端应用程序正在读取用户证书属性,如下面的代码所示 客户端应用程序是用C#编写的,这就是它从LDAP服务器读取证书的方式: using (DirectoryEntry entry = new DirectoryEntry("LDAP://[ldapAddress]"

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

问题是我只能在
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);
            }
        }
    }
}
使用(DirectoryEntry=newdirectoryentry(“LDAP://[ldapAddress]”)
{
entry.AuthenticationType=AuthenticationTypes.None;
使用(DirectorySearcher=new DirectorySearcher())
{
searcher.SearchRoot=条目;
searcher.Filter=“objectClass=inetOrgPerson”;
SearchResultCollection results=searcher.FindAll();
foreach(搜索结果中的搜索结果)
{
字节[]缓冲区=新字节[0];
if(result.Properties.Contains(“userCertificate”)&&(result.Properties[“userCertificate”]!=null))
{
buffer=result.Properties[“userCertificate”].Cast().First();
X509Certificate2证书=新的X509Certificate2(缓冲区);
}
}
}
}

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

我找到了一个解决方案。现在,我已经设置了一个LDAP服务器,该服务器正在与客户机应用程序一起工作。虽然我在OpenLDAP中没有做到这一点,但我安装了ApacheDS。ApacheDS允许将证书存储在
userCertificate
属性中,而无需
;二进制
选项

当然,这并不能解决如何在OpenLDAP上实现这一点,但安装ApacheDS对我来说已经足够好了

当然,欢迎任何关于如何在OpenLDAP中实现这一点的解决方案