Partager via


Using COM Interop to Access ADSI

System.DirectoryServices redefines selected, commonly used data structures and constants that are provided in ADSI. However, during the transition between COM applications and managed code applications, there will be situations in which you will want a managed code application to have access to the features that are provided by low-level ADSI structures or advanced interfaces.

To provide this interoperability between the underlying ADSI and managed code, the common language runtime has provided COM interop, which you can use to access any ADSI feature. This topic describes how to use COM interop to access ADSI.

Setting up COM Interop in Your Application

  1. Open Visual Studio and create a new project.

  2. From Project, click Add References... to open the Add Reference dialog.

  3. Click the COM tab.

  4. Select Active DS Type Library from the list in the Add Reference dialog box.

  5. Click OK to add the ADSI library.

Instead of a reference you can add a using statement to your application, as shown in the following code example.

using ActiveDs;
Imports ActiveDs

If you do not add a reference or a using statement, you must add the fully-qualified name for the ADSI library as shown in the following code example.

ActiveDs.IADsSecurityDescriptor

See Also

Reference

System.DirectoryServices

Concepts

Advanced Programming Topics

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.