Introduction to the ActiveDirectory Namespace
In chapter 2, we briefly outlined a new namespace in version 2.0 of the .NET Framework, System.DirectoryServices.ActiveDirectory (SDS.AD). SDS.AD adds a large number of new classes to the .NET directory services programming landscape that make managing Active Directory and ADAM significantly easier.
We already jumped into some of the features of SDS.AD in Chapter 7, when we demonstrated its new schema management features. Because the namespace is so large, we could probably spend an entire book discussing all of the features available to us. However, since we have limited space and time here, we have decided to focus this chapter on the parts of the namespace that we believe will be most useful for enterprise developers.
We start with the DirectoryContext class. DirectoryContext is used to initialize many of the other classes in the namespace. As such, it is the key to understanding how to use everything else.
We then move on to a discussion of locating domain controllers. This is probably the most useful feature for enterprise developers in SDS.AD, and the one we use the most often in our work.
We spend a little bit of time discussing how SDS.AD works its magic by marrying together the ADSI-based functionality of System.DirectoryServices (SDS) with some Windows APIs used to manage Active Directory. Understanding the underpinnings helps developers using .NET Framework version 1.x know how to accomplish similar things on their own, without SDS.AD, and gives all of us a better understanding of how things work.
We wrap up with some samples demonstrating our favorite nuggets and gems included in the new namespace that can make our normal SDS programming easier.