6

I understand that System.DirectoryServices is a "layer above" System.DirectoryServices.Protocols and abstracts some of the complexity.

Are there any other advantages, performance or otherwise, to using System.DirectoryServices.DirectorySearcher vs. System.DirectoryServices.Protocols.SearchRequest for LDAP queries from .NET.

What criteria would cause you to use one approach over the other?

1 Answer 1

11

Having dealt with both libraries a lot over the last few months, I can tell you there are some big differences, especially if you're dealing with large datasets. This blog post outlines just a few of the problems, and having dealt with LDAP instances containing over 500,000 entries, I can vouch for its accuracy.

The System.DirectoryServices namespace uses a lot of ADSI and COM under the surface which can add a lot of overhead, particularly with disposing objects. The System.DirectoryServices.Protocols interacts directly with the low level LDAP APIs, giving you much more control and much better interoperability with non-Microsoft directories.

If all you're trying to achieve is some quick and easy connectivity to an AD/ADAM/ADLDS instance for relatively simple operations, it might be worth sticking with that namespace - otherwise, I would strongly recommend you invest the time to learn the Protocols namespace. I found this MSDN article to be a huge help when I was learning originally - it covers pretty much everything you'll need to know.

2
  • Great answer..thanks. You hit right on a couple of my pain points: 1) Very large LDAP instances, and 2) non-AD LDAP's (we're using Tivoli Directory Services).
    – WayneC
    Apr 16, 2010 at 17:12
  • That article from MSDN has moved :(
    – Bryan
    Nov 7, 2012 at 15:21

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.