home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / Start / Child / vc / Child.cpp next >
Encoding:
C/C++ Source or Header  |  1999-01-19  |  1.1 KB  |  49 lines

  1. // Child.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stdio.h"
  6. #include "activeds.h"
  7.  
  8. #define RETURN_ON_FAILURE(hr) if(!SUCCEEDED(hr)) return hr;
  9.  
  10.  
  11. int main(int argc, char* argv[])
  12. {
  13.     HRESULT hr;
  14.  
  15.     CoInitialize(NULL);
  16.  
  17.     IADsContainer *pCont=NULL;
  18.  
  19.     hr = ADsGetObject(L"LDAP://DC=windows2000,DC=nttest,DC=microsoft,DC=com",
  20.                       IID_IADsContainer, 
  21.                       (void**) &pCont );
  22.  
  23.     RETURN_ON_FAILURE(hr);
  24.     
  25.  
  26.     /////////////////////////////////////////////////////////////
  27.     // Get the child from the container 
  28.     // Note in the LDAP provider you can go down more than one level
  29.     ///////////////////////////////////////////////////////////////
  30.     IDispatch *pDisp = NULL;
  31.     IADs      *pADs  = NULL;
  32.     hr = pCont->GetObject(L"user", L"CN=Mike Smith, OU=DSys", &pDisp );
  33.     pCont->Release();
  34.  
  35.     RETURN_ON_FAILURE(hr);
  36.  
  37.     
  38.     hr = pDisp->QueryInterface( IID_IADs, (void**) &pADs );
  39.     pDisp->Release();        
  40.     RETURN_ON_FAILURE(hr);
  41.  
  42.     // ... do something with pADs here .
  43.     pADs->Release();
  44.  
  45.  
  46.     CoUninitialize();
  47.     return 0;
  48. }
  49.