我是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。