By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

C# to OpenLDAP

P: n/a
Hi all,

I have a problem. Been pulling my hair out all day with this. Had a number
of errors, but now I am so close. This is connecting to OpenLDAP on a linux
box. My app is an ASP.NET app in C#.
System.DirectoryServices.DirectoryEntry entryPC = new

entryPC.Path =

string sFilter =
String.Format("(&(objectClass=pen)(description={0} ))", PenIDTextBox.Text);
entryPC.AuthenticationType =
System.DirectoryServices.AuthenticationTypes.Anony mous;

System.DirectoryServices.DirectorySearcher ds = new
System.DirectoryServices.DirectorySearcher(entryPC );
ds.Filter = sFilter;

ds.SearchScope = System.DirectoryServices.SearchScope.Subtree;

System.DirectoryServices.SearchResult sr = null;

bool SRFailed = false;

sr = ds.FindOne();
catch(Exception ex)
SRFailed = true;
The path is correct as I can connect to it with an LDAP Browser.

When I run it, I am dropping into the catch and getting an error "The
parameter is incorrect", which is about as helpful as praying for it to
Inside my ou=pens, I have a branch (an endpoint) of serialNumber=0x000....
(hex number). There are two of these. Inside these, I have various
attributes, 3 objectClass (one of them has the value "pen" and a description
attribute with the value that I am searching for.

If I put my sFilter value in my LDAP Browser search routine, then I get the
result (but only if I scan the subtree).

Absolutely any help, even if you don't know the answer but possible have
noticed something I may have missed will be helpful.


Best regards,
Dave Colliver.
~~ - Local franchises available
Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.