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

  1. // Move.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.  
  9. int main(int argc, char* argv[])
  10. {
  11.     CoInitialize(NULL);
  12.     
  13.  
  14.     ////////////////////////////////////////////
  15.     // First bind to the destination container
  16.     ////////////////////////////////////////////
  17.     HRESULT hr;
  18.     IADsContainer *pCont=NULL;
  19.     hr = ADsGetObject(L"LDAP://OU=MCS,DC=windows2000,DC=nttest,DC=microsoft,DC=com",
  20.                       IID_IADsContainer,
  21.                       (void**) &pCont );
  22.  
  23.     if ( !SUCCEEDED(hr) )
  24.     {
  25.         return 0;
  26.     }
  27.  
  28.     /////////////////////////////////////////////////
  29.     // Now, move the object to the bound container
  30.     ///////////////////////////////////////////////////
  31.     IDispatch *pDisp=NULL;
  32.  
  33.     hr = pCont->MoveHere(L"LDAP://CN=Mike Smith,OU=DSys,DC=windows2000,DC=nttest,DC=microsoft,DC=com", NULL, &pDisp );
  34.     pCont->Release();
  35.  
  36.     if (SUCCEEDED(hr) )
  37.     { 
  38.         // You may do other operation here, such as updating attributes
  39.         pDisp->Release();
  40.     }
  41.                          
  42.  
  43.     CoUninitialize();
  44.     return 0;
  45. }
  46.