Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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);
                 }
Posted
Updated 26-Oct-15 20:47pm
v2

1 solution

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
 
Share this answer
 
Comments
Korathu123 27-Oct-15 6:38am    
I want to work using LDAP server itself code wise.
Garth J Lancaster 27-Oct-15 7:10am    
well, good luck searching for the object - the best you can do is hit and miss searches until you get it right

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900