2014-12-03 89 views
0

我是LDAP新手(约1周)。而且我需要设置LDAP服务器以便现有的客户端应用程序(不幸的是我无法对其进行更改)可以读取来自userCertificate属性的证书。为现有客户端应用程序配置OpenLDAP 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); 
      } 
     } 
    } 
} 

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

回答

0

我找到了解决方案。现在我已经建立了一个与客户端应用程序一起工作的LDAP服务器。尽管我没有在OpenLDAP中做到这一点,但是我已经安装了ApacheDS。而且ApacheDS允许在userCertificate属性中存储证书,而不需要;binary选项。

这当然不会回答如何在OpenLDAP上完成它,但安装ApacheDS对我来说已经足够好了。

当然,如何在OpenLDAP中实现这些解决方案是值得欢迎的。