Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any performance advantage to using DirectorySearcher over SearchRequest for LDAP queries

Tags:

.net

ldap

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?

like image 207
WayneC Avatar asked Apr 16 '10 00:04

WayneC


1 Answers

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.

like image 94
PatrickJ Avatar answered Sep 25 '22 00:09

PatrickJ