Leveraging .NET Framework Objects


The .NET Framework provides the System.DirectoryServices namespace to interact with directory services. It comprises two primary objects and a number of supporting objects. The DirectoryEntry and DirectorySearcher objects both interact directly with the underlying ADSI services. They are not limited to interaction with only Active Directory; custom providers can also enable interaction with other directory service solutions, such as Internet Information Services (IIS), LDAP, and Novell NDS.

Using the DirectoryEntry Object

The DirectoryEntry object abstracts a specific networked resource object in the directory service hierarchy. This object is primarily used for binding directly to such objects, retrieving properties, and updating properties. This object is largely a data storage object rich with properties but limited on functionality. The DirectoryEntry object provides support for life-cycle management and navigation methods , including creating, deleting, renaming, and moving a child node. Properties are largely divided into three areas: validation, node description, and schema related .

Using the DirectorySearcher Object

You use the DirectorySearcher object to search and perform queries against an Active Directory hierarchy. An administrator can create, delete, and edit objects within the hierarchy. A search of the object hierarchy using DirectorySearcher returns an instance of a SearchResult object. If more than one value is returned as a result of the search, then multiple instances are returned within a SearchResultCollection object. Setting the various DirectorySearcher properties affects how the directory services will be searched and how the results will be returned. When an instance of the DirectorySearcher object is created, the SearchRoot property can specify where in the hierarchy tree the search should begin. When searching any object tree, it is important to start the search as close as possible to the target node to minimize the search time.

Using the SearchResult Object

The SearchResult object abstracts an entry node in the directory service hierarchy. An instance of a SearchResult object is similar to an instance of the DirectoryEntry object. The most obvious difference is that the DirectoryEntry object is populated each time a new object is accessed. Conversely, a SearchResult object is populated as result of a DirectorySearcher query. Only those properties specified through the DirectorySearcher.PropertiesToLoad property's collection in your query will be available from SearchResult.




Developing. NET Enterprise Applications
Developing .NET Enterprise Applications
ISBN: 1590590465
EAN: 2147483647
Year: 2005
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net