共用方式為


Directory Services in the .NET Framework 

System.DirectoryServices, System.DirectoryServices.ActiveDirectory, and System.DirectoryServices.Protocols managed APIs provide directory service access and management. Together, these managed APIs provide a complete solution for developing directory-centric and directory-enabled applications using managed code.

The following graphic shows how the three managed APIs relate to each other and to the unmanaged counterparts.

Directory Services in .NET Framework

In This Section

  • System.DirectoryServices Namespace Overview
    Provides access to Active Directory from managed code. System.DirectoryServices is built on ADSI. DirectoryEntry and DirectorySearcher are the two base object types. All operations are executed around these two objects.

    When using System.DirectoryServices, there is no need to understand advanced concepts. For example, when using LDAP controls to perform a paged search, specify the page size and enumerate returned results. Everything, from constructing a page result control, sending requests, and obtaining a page result cookie, to reissuing requests, is handled by System.DirectoryServices. Users are not required to understand the property syntax; it is handled automatically through internal schema mapping.

    System.DirectoryServices is designed for developers who perform rapid application development for line-of-business applications and directory-enabled applications.

  • System.DirectoryServices.ActiveDirectory Namespace Overview
    Provides a high-level abstraction object model that builds around Active Directory tasks. The Active Directory concepts such as forest, domain, site, subnet, partition, and schema are part of the object model.

    System.DirectoryServices.ActiveDirectory is built on System.DirectoryServices and has features similar to System.DirectoryServices. Unlike System.DirectoryServices or System.DirectoryServices.Protocols which provides general access to directories, System.DirectoryServices.ActiveDirectory provides more abstraction and is centered on all the tasks and operations for Active Directory and Active Directory Application Mode (ADAM). For example, System.DirectoryServices.ActiveDirectory is used to find domain controllers in a particular domain, to replicate ADAM instances, to set up trusts, and to create topologies. The System.DirectoryServices.ActiveDirectory namespace is designed for administrators who want to automate daily tasks and for IT developers who create Active Directory or ADAM-related line-of-business applications.

  • System.DirectoryServices.Protocols Namespace Overview
    Designed for the Lightweight Directory Access Protocol (LDAP) and similar protocols such as Directory Services Markup Language (DSML). It is not a high-level abstraction API. The object model of System.DirectoryServices.Protocols is connection oriented, requests are constructed and sent over the connection, and response are received and returned through the connection. System.DirectoryServices.Protocols is built on top LDAP C programming language API. The goal is high performance and System.DirectoryServices.Protocols provides full LDAP functionality. The advanced features include an asynchronous model, certificate support, and LDAP controls. System.DirectoryServices.Protocols is targeted for experienced developers that seek maximum control and flexibility to develop high performance server-side applications.