How To Find All ADSI Providers on a System

Article translations Article translations
Article ID: 233023 - View products that this article applies to.
This article was previously published under Q233023
Expand all | Collapse all

On This Page


Microsoft Active Directory Service Interfaces (ADSI) is built on a provider model, where clients interact with ADSI interfaces to perform directory manipulation, while providers implement the mapping between the directory and ADSI interfaces.

This article shows you how to find and list all ADSI providers on a system.


This can be accomplished by enumerating ADs namespace members with the following code for both Microsoft Visual C++ and Microsoft Visual Basic.

Visual C++

Using Visual C++ paste the following code into a Microsoft C++ Source File:
#include <activeds.h>
#include <stdio.h>
// link with activeds.lib and adsiid.lib

void main()
	IEnumVARIANT   *pEnum;
	IADsContainer  *pCont;
	IADs           *pADs;
	IDispatch      *pDisp;
	VARIANT        var;
	BSTR           bstr;
	ULONG          lFetch;
	HRESULT        hr;

	// Skipping error checking for simplicity

	// Bind to ADs namespace
	hr = ADsGetObject(L"ADs:",IID_IADsContainer, (void**) &pCont);
	//Create an enumerator object in the container.
	hr=ADsBuildEnumerator(pCont, &pEnum);
	// Now enumerate through all providers 
	while(hr == S_OK)
		hr = ADsEnumerateNext(pEnum, 1, &var, &lFetch);
		if (lFetch == 1)
			pDisp = V_DISPATCH(&var);
			pDisp->QueryInterface(IID_IADs, (void**)&pADs);

    //Release the enumerator.
    if (pEnum != NULL)

Visual Basic

First make a reference to the "Active DS Type Library" by selecting References from the Visual Basic Tools menu. Then paste the following code into a Visual Basic standard module:
Dim prov As IADsNamespaces
Dim member As IADs

Set prov = GetObject("ADs:")
For Each member In prov
   Debug.Print member.Name


For additional information about ADSI, please visit:


Article ID: 233023 - Last Review: September 28, 2007 - Revision: 2.3
  • Microsoft Active Directory Service Interfaces 2.0
  • Microsoft Active Directory Service Interfaces 2.5
kbhowto KB233023
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from