The System.DirectoryServices namespace contains several classes, many of which were built on top of ADSI. If you are already familiar with ADSI, the learning curve for the System.DirectoryServices classes should be pretty minimal. Table 28-1 contains the base classes contained within the System.DirectoryServices namespace.
Class name |
Description |
---|---|
DirectoryEntries |
Contains the children (child entries) of an entry in Active Directory. |
DirectoryEntry |
Encapsulates a node or object in the Active Directory hierarchy. |
DirectorySearcher |
Performs queries against Active Directory. |
DirectoryServicesPermission |
Allows control of code access security permissions for System.DirectoryServices. |
DirectoryServicesPermissionAttribute |
Allows declarative System.DirectoryServices permission checks. |
DirectoryServicesPermissionEntry |
Defines the smallest unit of a code access security permission set for System.DirectoryServices. |
DirectoryServicesPermissionEntryCollection |
Contains a strongly typed collection of DirectoryServicesPermissionEntry objects. |
PropertyCollection |
Contains the properties of a DirectoryEntry. |
PropertyValueCollection |
Contains the values of a DirectoryEntry property. |
ResultPropertyCollection |
Contains the properties of a SearchResult instance. |
ResultPropertyValueCollection |
Contains the values of a SearchResult property. |
SchemaNameCollection |
Contains a list of the schema names that the SchemaFilter property of a DirectoryEntries object can use. |
SearchResult |
Encapsulates a node in the Active Directory hierarchy that is returned during a search through DirectorySearcher. |
SearchResultCollection |
Contains the SearchResult instances that the Active Directory hierarchy returned during a DirectorySearcher query. |
SortOption |
Specifies how to sort the results of a search. |
|
The two main classes within System.DirectoryServices are DirectoryEntry and DirectorySearcher. The DirectoryEntry class represents an object in Active Directory. You can create new objects and manage existing ones with DirectoryEntry. The DirectorySearcher class is the primary interface for searching Active Directory. It is an easy-to-use interface that contains properties for all the typical options you need to set when performing LDAP-based queries. We will be touching on some of the other classes as we go along, but these two are the main ones to become familiar with.