home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / Start / First / First.cpp next >
Encoding:
C/C++ Source or Header  |  1999-01-14  |  885 b   |  55 lines

  1. // First.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "activeds.h"
  6.  
  7. int main(int argc, char* argv[])
  8. {
  9.     HRESULT hr;
  10.     IADsContainer *pCont;
  11.  
  12.     CoInitialize(NULL);
  13.  
  14.     hr = ADsGetObject(L"WinNT://YOURDOMAIN", IID_IADsContainer, (void**) &pCont );
  15.     
  16.     if ( !SUCCEEDED(hr) )
  17.     {
  18.         return 0;
  19.     }
  20.  
  21.     //----------------------------
  22.     // Creating a user
  23.     //-----------------------------
  24.     IDispatch *pDisp=NULL;
  25.     IADs *pUser;
  26.     hr = pCont->Create( L"user", L"jsmith", &pDisp );
  27.     pCont->Release();
  28.     
  29.     if ( !SUCCEEDED(hr) )
  30.     {
  31.         return 0;
  32.     }
  33.  
  34.     hr = pDisp->QueryInterface( IID_IADs, (void**) &pUser );
  35.     pDisp->Release();
  36.  
  37.     if ( !SUCCEEDED(hr) )
  38.     {    
  39.         return 0;
  40.     }
  41.  
  42.  
  43.  
  44.     // Commit creation to the directory
  45.     pUser->SetInfo();
  46.  
  47.     // Release the object
  48.     pUser->Release();
  49.     
  50.  
  51.     CoUninitialize();
  52.  
  53.     return 0;
  54. }
  55.