Leaked source code of windows server 2003
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.

97 lines
2.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // Cracker.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares the class NameCracker.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 04/13/1998 Original version.
  16. // 08/10/1998 Remove NT4 support.
  17. // 08/21/1998 Removed initialization/shutdown routines.
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #ifndef CRACKER_H_
  21. #define CRACKER_H_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif
  25. #include "guard.h"
  26. #include "nocopy.h"
  27. #include <ntdsapi.h>
  28. // Forward declaration of helper class used by NameCracker.
  29. class DsHandle;
  30. ///////////////////////////////////////////////////////////////////////////////
  31. //
  32. // CLASS
  33. //
  34. // NameCracker
  35. //
  36. // DESCRIPTION
  37. //
  38. // This class wraps the DsCrackNames API. It adds functionality for
  39. // connection caching and transparent retry of failed queries.
  40. //
  41. ///////////////////////////////////////////////////////////////////////////////
  42. class ATL_NO_VTABLE NameCracker
  43. : Guardable, NonCopyable
  44. {
  45. public:
  46. NameCracker() throw ();
  47. ~NameCracker() throw ();
  48. // Non-connection oriented version of DsCrackNames.
  49. DWORD crackNames(
  50. DS_NAME_FLAGS flags,
  51. DS_NAME_FORMAT formatOffered,
  52. DS_NAME_FORMAT formatDesired,
  53. PCWSTR name,
  54. PCWSTR upnSuffix,
  55. PDS_NAME_RESULTW *ppResult
  56. ) throw ();
  57. // Wrapper around the DsFreeNameResultW.
  58. void freeNameResult(DS_NAME_RESULTW *pResult) throw ()
  59. { DsFreeNameResultW(pResult); }
  60. protected:
  61. // Discards the cached GC handle. Used to shutdown a bad connection.
  62. void disable(DsHandle* h) throw ();
  63. // Get a handle to the Global Catalog.
  64. DWORD getGC(DsHandle** h) throw ();
  65. // Current connection to the Global Catalog.
  66. DsHandle* gc;
  67. private:
  68. DWORD processSID(
  69. PCWSTR name,
  70. PCWSTR upnSuffix,
  71. DS_NAME_FORMAT& newFormatOffered,
  72. wchar_t** ppUpnString) throw();
  73. bool convertSid2Puid(PCWSTR sidString, LARGE_INTEGER& puid) throw();
  74. DWORD convertPuid2String(
  75. const LARGE_INTEGER& puid,
  76. wchar_t* upnString,
  77. DWORD upnStringCch,
  78. const wchar_t* suffix
  79. ) throw();
  80. };
  81. #endif // CRACKER_H_