Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

An easy to use class to list Active Directory Users

0.00/5 (No votes)
1 Apr 2004 1  
A very simple class which can list all the Active Directory users just by calling a single member function.

Sample Image - ADUsers.jpg

Introduction

The purpose of this very brief text is to present a simple class CActiveDirectoryUser. This is a very easy to use C++ class in which you can simply list all the users in the ActiveDirectory by just a single function call. The code inside the class is very simple. It actually wraps some ADSI calls and can be easily understood.

Usage

CActiveDirectoryUsers ADUsers;
CStringArray Array;
bool res=ADUsers.GetADUsers(Array);
if(!Array.IsEmpty()&&res)
for(int i=0;i<Array.GetCount();i++)
{
 CString strUser=Array.GetAt(i);
 //Do whatever

}

The function GetADUsers() returns false in case of failure and returns true in case of success, so the CStringArray contents will be only valid if the return value is true.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here