Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.1 KiB

  1. // ADSI Helper functions
  2. //
  3. // Copyright (c) 2001 Microsoft Corporation
  4. //
  5. // 1 Mar 2001 sburns
  6. #ifndef ADSIHELPERS_HPP_INCLUDED
  7. #define ADSIHELPERS_HPP_INCLUDED
  8. // CODEWORK: consider putting this, and some of the more general purpose
  9. // adsi goodies from admin\snapin\localsec\src\adsi.hpp|.cpp into an
  10. // adsi header in burnslib.
  11. // Template function that actually calls ADsOpenObject.
  12. //
  13. // Interface - The IADsXXX interface of the object to be bound.
  14. //
  15. // path - in, The ADSI path of the object to be bound.
  16. //
  17. // ptr - out, A null smart pointer to be bound to the interface of the object.
  18. template <class Interface>
  19. HRESULT
  20. AdsiOpenObject(
  21. const String& path,
  22. SmartInterface<Interface>& ptr)
  23. {
  24. LOG_FUNCTION2(AdsiOpenObject, path);
  25. ASSERT(!path.empty());
  26. Interface* p = 0;
  27. HRESULT hr =
  28. ::ADsOpenObject(
  29. path.c_str(),
  30. 0,
  31. 0,
  32. ADS_SECURE_AUTHENTICATION,
  33. __uuidof(Interface),
  34. reinterpret_cast<void**>(&p));
  35. if (SUCCEEDED(hr))
  36. {
  37. ptr.Acquire(p);
  38. }
  39. LOG_HRESULT(hr);
  40. return hr;
  41. }
  42. #endif // ADSIHELPERS_HPP_INCLUDED