Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Active directory Interfaces > Connecting to O...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 2273 of 2407
Post > Topic >>

Connecting to OpenLDAP from C#

by "David" <david.colliver.NEWS@[EMAIL PROTECTED] > May 9, 2008 at 04:54 PM

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 
System.DirectoryServices.DirectoryEntry();

            entryPC.Path = 
"LDAP://MyLDAPServer389/ou=pens,dc=anotes,dc=com";

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

            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;

            try
            {
                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 
work.


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.

Thanks.

-- 
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUS****tals.com
- Local franchises available
 




 4 Posts in Topic:
Connecting to OpenLDAP from C#
"David" <dav  2008-05-09 16:54:59 
Re: Connecting to OpenLDAP from C#
"Joe Kaplan" &l  2008-05-09 12:02:56 
Re: Connecting to OpenLDAP from C#
"David" <dav  2008-05-09 20:51:24 
Re: Connecting to OpenLDAP from C#
"Joe Kaplan" &l  2008-05-09 16:18:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Dec 4 22:17:57 CST 2008.