Talk About Network

Google





Software > Active directory Interfaces > Re: Connecting ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 2273 of 2411
Post > Topic >>

Re: Connecting to OpenLDAP from C#

by "Joe Kaplan" <joseph.e.kaplan@[EMAIL PROTECTED] > May 9, 2008 at 04:18 PM

Glad to help.  I had to figure that out when I was trying to do***ent that 
parameter for the chapter of my book that describes it.  :)

It is actually used almost never with AD programming (the main audience of

the .NET LDAP stacks) since AD is pretty useless when accessed
anonymously, 
but it does come up from time to time.

Joe K.
-- 
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services
Programming"
http://www.directoryprogramming.net
--
"David" <david.colliver.NEWS@[EMAIL PROTECTED]
> wrote in message 
news:uB$p74gsIHA.5096@[EMAIL PROTECTED]
> Excellent. You are a star...
>
> I would never have got that. Who'd have thought that when connecting
anon 
> that you need to pass empty credentials. It now works. Thank you.
>
> The information I need from this system is available anonymously. I have

> connected successfully and anonymously with an LDAP browser by Jarek
Gower 
> and know that the path was indeed correct.
>
> All I needed the info for was to check the existence of a 'pen', just
like 
> the existance of a user. If it exists, then I am happy.
>
> -- 
> Best regards,
> Dave Colliver.
> http://www.AshfieldFOCUS.com
> ~~
> http://www.FOCUS****tals.com
- Local franchises available
>
>
> "Joe Kaplan" <joseph.e.kaplan@[EMAIL PROTECTED]
> wrote in message

> news:uj%23JIafsIHA.4076@[EMAIL PROTECTED]
>> First off, I generally recommend people use 
>> System.DirectoryServices.Protocols for connecting to non-MS LDAP 
>> databases. S.DS will work in some cases, but it can often times cause 
>> friction as well. S.DS.P is more "pure LDAP" and often results in
reduced 
>> friction at the expense of being slightly more complicated.
>>
>> That said, if you want to use AuthenticationTypes.Anonymous, you have
to 
>> supply "" for the username and password.  If you supply null/nothing,
it 
>> will not work.
>>
>> Make sure you really really do want to connect anonymously.  It is
often 
>> the case that anonymous users in LDAP directories can't actually see
any 
>> useful results.  You may need to bind successfully first.
>>
>> Best of luck!
>>
>> Joe K.
>> -- 
>> Joe Kaplan-MS MVP Directory Services Programming
>> Co-author of "The .NET Developer's Guide to Directory Services 
>> Programming"
>> http://www.directoryprogramming.net
>> --
>> "David" <david.colliver.NEWS@[EMAIL PROTECTED]
> wrote in message 
>> news:edW8u0esIHA.3420@[EMAIL PROTECTED]
>>> 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
localhost-V2008-12-19 Thu Jan 8 7:39:54 PST 2009.