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

  1. // Delete.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. int main(int argc, char* argv[])
  9. {
  10.     HRESULT hr;
  11.     IADsContainer *pCont=NULL;
  12.  
  13.     CoInitialize(NULL);
  14.  
  15.     hr = ADsGetObject(L"WinNT://INDEPENDENCE", IID_IADsContainer, (void**) &pCont);
  16.     if ( !SUCCEEDED(hr) )
  17.     {
  18.         return 0;
  19.     }
  20.  
  21.     ///////////////////////////////////////////////////
  22.     // Using IADsContainer::Delete to delete a user
  23.     //////////////////////////////////////////////////
  24.     hr = pCont->Delete(L"user", L"AliceW");
  25.     pCont->Release();
  26.  
  27.     /////////////////////////////////////////////////////////////
  28.     // Using IDirectoryObject::DeleteDSObject to delete a user
  29.     //////////////////////////////////////////////////////////////
  30.     IDirectoryObject *pDirObject=NULL;
  31.  
  32.     hr = ADsGetObject(L"LDAP://OU=DSys,DC=windows2000,DC=nttest,DC=microsoft,DC=com",
  33.                       IID_IDirectoryObject, (void**) &pDirObject );
  34.  
  35.     if ( SUCCEEDED(hr) )
  36.     {
  37.         hr = pDirObject->DeleteDSObject(L"CN=Mike Smith");
  38.         pDirObject->Release();
  39.     }
  40.     
  41.  
  42.     CoUninitialize();
  43.  
  44.     return 0;
  45. }
  46.