如何将证书添加到LDAP服务器创建? [英] How to add a certificate to LDAP server created?

查看:189
本文介绍了如何将证书添加到LDAP服务器创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将证书添加到创建的LDAP服务器?



我创建了一个名为NESTIT-283的LDAP服务器。但有了它,我就可以单独获取objectclass,adspath,domain组件。

我的代码如下:

How to add a certificate to LDAP server created?

I created a LDAP Server with name NESTIT-283. But with it I am able to fetch the objectclass,adspath,domain component alone.
My code is as below:

DirectoryEntry de = new DirectoryEntry("LDAP://NESTIT-283/dc=maxcrc,dc=com");//Where ##### is the name of your AD server
                  de.AuthenticationType = AuthenticationTypes.None;
                  DirectorySearcher dsearch = new DirectorySearcher(de);
                  //dsearch.Filter = "(cn=Alexander.junior)"; //Search how you want.  Google "LDAP Filter" for more.
                  SearchResultCollection rc = dsearch.FindAll();
                  int cnt = rc.Count;
                  X509Certificate stt = new X509Certificate();

                  foreach (SearchResult r in rc)
                  {
                      string s = r.Properties["objectClass"][0].ToString();
                      string s1 = r.Properties["adspath"][0].ToString();
                      string s2 = r.Properties["dc"][0].ToString();

                      if (r.Properties.Contains("userCertificate"))
                      {
                          
                          Byte[] b = (Byte[])r.Properties["userCertificate"][0];  //This is hard coded to the first element.  Some users may have multiples.  Use ADSI Edit to find out more.
                          X509Certificate cert1 = new X509Certificate(b);
                      }
                  }

推荐答案

你好



存储证书可按以下方式完成



hello

to store certificate it could be done as follow

byte[] certData = (byte[]) r.Properties["userCertificate"][0];
X509Certificate cert = new X509Certificate(certData);
r.Properties["userCertificate"].Clear();
r.CommitChanges();
r.Properties["userCertificate"].Add(cert.GetRawCertData());
r.CommitChanges();







我希望它会有所帮助,那是你在找什么




I hope that it would help and that was what you were looking for


这篇关于如何将证书添加到LDAP服务器创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆