I am trying to connect to a Domino server to get all users information (name, email, etc). When I try to run the below code I get the following error: {“A protocol error occurred.\r\n”}
I have looked around and tried this same query in a ldap browser and all worked fine. Any advice is appreciated.
DirectorySearcher search = new DirectorySearcher(new DirectoryEntry("LDAP://server:port"));
try
{
search.Filter = "(objectClass=dominoPerson)";
search.PropertiesToLoad.Add("cn");
SearchResultCollection results = search.FindAll();
foreach (SearchResult r in results)
{
DirectoryEntry de = r.GetDirectoryEntry();
foreach (DirectoryEntry child in de.Children)
{
Console.WriteLine(child.Name);
}
}
search.Dispose();
}
catch (Exception msg)
{
Console.WriteLine(msg.ToString());
}v
Are you authenticating with the ldap browser but doing an unauthenticated query from your code? Depending on configuration settings, Domino may reject unauthenticated queries altogether, or limit the attributes that it will return. Also, are you specifying a BaseDN in your ldap browser connection but not in your code?
Rather than just guessing, though, I’d suggest collecting as much information as possible on the server side. I.e., set up debug logging on the Domino server to capture information about your LDAP connection and request. Use the server command set config LDAPDEBUG=7, and then restart the ldap task. (You can set it to 3 to start with, for less verbose output, but IMHO you probably might as well go right to the maximum level of info.)
Once you have that set up, do the query with the ldap browser and watch the Domino server’s console. (If it scrolls out of the visible window, you should be able to find the log info in the IBM Technical Support folder on the server.) Next, enter a server command (e.g. “show server”) just to serve as an easily visible separator, and then run your code and watch the console log.
At this point you should be able to compare the console log entries from the ldap browser connection and query against the entries from your code’s connection and query. The differences should lead you toward a solution.