tags:

views:

161

answers:

1

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?

+3  A: 

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.

PatrickJ
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