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

  1. // Binding.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.     HRESULT hr;
  15.     IADs *pADs = NULL;
  16.     /////////////////////////////////////////
  17.     // Binding as currently logged on user
  18.     ////////////////////////////////////////
  19.     hr = ADsGetObject( L"WinNT://INDEPENDENCE/JSmith,user", IID_IADs, (void**) &pADs );
  20.  
  21.     if ( !SUCCEEDED(hr) )
  22.     {
  23.         return hr;
  24.     }
  25.  
  26.     //... do some operations here
  27.     pADs->Release(); // Do not forget to release when you're done.
  28.  
  29.  
  30.     /////////////////////////////////////////
  31.     // Binding with alternate credentials
  32.     ////////////////////////////////////////
  33.     hr = ADsOpenObject(L"WinNT://INDEPENDENCE/JSmith,user", L"Administrator", L"secret", ADS_SECURE_AUTHENTICATION, IID_IADs, (void**) &pADs );
  34.     if ( !SUCCEEDED(hr) )
  35.     {
  36.         return hr;
  37.     }
  38.  
  39.     //...
  40.     // Make sure you release it after use
  41.     pADs->Release();
  42.  
  43.  
  44.  
  45.     CoUninitialize();
  46.     return 0;
  47. }
  48.