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