Click here to Skip to main content
11,706,455 members (47,817 online)
Click here to Skip to main content

User Management using ADSI

, 23 Mar 2001 124.3K 1.1K 24
Rate this:
Please Sign up or sign in to vote.
This article demonstrates user management using Active Directory Services

Sample Image - adsiuserdmo.gif


The listing demonstrates how to use Active Directory Service to manage the users on WinNT and Windows 2000.

IADsContainer interface lets you crawl through the active directory. To manage users, you need to get ADS object with path WinNT://DomianName/MachineName. IADsWinNTSystemInfo interface provides this information. Once we have a container, we enumerate through the container and if the object supports IADsUser interface, we add it as the user in the ListView. IADsUser then lets you manage properties for individual users.

//Get the Information about system name and domain name

IADsWinNTSystemInfo *pNTsys;
HRESULT hr = CoCreateInstance(CLSID_WinNTSystemInfo, 
   IID_IADsWinNTSystemInfo,  (void**)&pNTsys);
BSTR bstrCompName;
CString cscompName=bstrCompName;
BSTR bstrDomainName;
CString CSDomainName=bstrDomainName;

//Form ADSPath

//Get the container object
hr=ADsGetObject(ADSPath.AllocSysString(),IID_IADsContainer,(void **)&pUsers);

//Now Enumerate through the container
IEnumVARIANTPtr pEnum; 
ADsBuildEnumerator (pUsers,&pEnum);
int cnt=0;
    _variant_t vChild;
    hr=ADsEnumerateNext (pEnum,1,&vChild,NULL);
    //Iterate as long as you get S_OK 
    hr=vChild.pdispVal->QueryInterface (IID_IADsUser,(void **)&pChild);
        //This object is user


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


About the Author

Vineet Nandurkar
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralI still have unresolved externals Pin
zim32726-Aug-04 5:07
memberzim32726-Aug-04 5:07 
GeneralRe: I still have unresolved externals Pin
zim32726-Aug-04 9:47
memberzim32726-Aug-04 9:47 
GeneralRe: I still have unresolved externals Pin
kelprinc29-Jan-06 22:57
memberkelprinc29-Jan-06 22:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 24 Mar 2001
Article Copyright 2001 by Vineet Nandurkar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid