为什么异常“在服务器上找不到对象”进入LDAP? [英] Why the exception "No Object Found on Server" is coming in LDAP ?

查看:642
本文介绍了为什么异常“在服务器上找不到对象”进入LDAP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LDAP服务器。我安装了相同的并尝试从LDAP服务器获取证书。

我收到异常在服务器上找不到对象。服务器连接正常。

我的代码如下:

I am using LDAP server. I installed the same and trying to fetch the certificates from LDAP server.
I am getting the exception "No Object Found on Server". The server connection is coming fine.
My code is as below:

DirectoryEntry rootEntry = new DirectoryEntry("LDAP://NESTIT-283:389");


                 rootEntry.AuthenticationType = AuthenticationTypes.None; //Or whatever it need be
                 DirectorySearcher searcher = new DirectorySearcher(rootEntry);
                 string searchString = "(CN = EFTS-CA-TEST)";
                 var queryFormat = "(&(objectClass=user)(objectCategory=person)(|(SAMAccountName=*{0}*)(cn=*{0}*)(gn=*{0}*)(sn=*{0}*)(email=*{0}*)))";
                 //searcher.Filter = string.Format(queryFormat, searchString);

                 searcher.Filter = searchString;//Search how you want.  Google "LDAP Filter" for more.
                 foreach (SearchResult result in searcher.FindAll())
                 {
                     Console.WriteLine("account name: {0}", result.Properties["samaccountname"].Count > 0 ? result.Properties["samaccountname"][0] : string.Empty);
                     Console.WriteLine("common name: {0}", result.Properties["cn"].Count > 0 ? result.Properties["cn"][0] : string.Empty);
                 }

推荐答案

您是否尝试过使用LDAP浏览器工具手动定位证书并比较其属性使用您在搜索中指定的属性?



也许 http://ldaptool.sourceforge .net / [ ^ ]可能有效,否则有很多类似的免费工具
Have you tried using an LDAP Browser tool to locate the certificate manually and compare its attributes with the attributes you specify in your search ?

Maybe http://ldaptool.sourceforge.net/[^] might work, else there are plenty of similar and free tools out there


这篇关于为什么异常“在服务器上找不到对象”进入LDAP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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