2014-12-03 90 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中實現這些解決方案是值得歡迎的。