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.

116 lines
1.9 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2002
  3. Module Name:
  4. sidcache.hxx
  5. Abstract:
  6. Header for the SID_CACHE class.
  7. Author:
  8. Maurice Flanagan (mauricf) June 27, 2002
  9. Revision History:
  10. --*/
  11. RPC_STATUS
  12. InitializeSIDCache(
  13. );
  14. RPC_STATUS
  15. QuerySIDCache(
  16. IN RPC_CHAR *ServerPrincipalName,
  17. OUT PSID *Sid
  18. );
  19. RPC_STATUS
  20. AddToSIDCache(
  21. IN RPC_CHAR *ServerPrincipalName,
  22. IN PSID Sid
  23. );
  24. RPC_STATUS
  25. RemoveFromSIDCache(
  26. IN RPC_CHAR *ServerPrincipalName
  27. );
  28. struct SID_CACHE_ENTRY
  29. {
  30. RPC_CHAR *SPN; // This is used as the index into the table, if NULL then this is an empty slot
  31. PSID SID; // IF the SPN is NULL, the SID must be NULL, if the SPN is not NULL, the SID must be non NULL
  32. DWORD Age;
  33. };
  34. class SID_CACHE
  35. {
  36. private:
  37. SID_CACHE_ENTRY Cache[4];
  38. MUTEX CacheMutex;
  39. public:
  40. SID_CACHE (
  41. RPC_STATUS *Status
  42. );
  43. ~SID_CACHE (
  44. );
  45. RPC_STATUS
  46. Query (
  47. IN RPC_CHAR *ServerPrincipalName,
  48. OUT PSID *Sid
  49. );
  50. RPC_STATUS
  51. Add (
  52. IN RPC_CHAR *ServerPrincipalName,
  53. IN PSID Sid
  54. );
  55. RPC_STATUS
  56. Remove (
  57. IN RPC_CHAR *ServerPrincipalName
  58. );
  59. };
  60. #define CacheSize 4
  61. extern SID_CACHE *SIDCache;
  62. inline
  63. SID_CACHE::SID_CACHE (
  64. RPC_STATUS *Status
  65. ) : CacheMutex(Status)
  66. {
  67. DWORD idx;
  68. for (idx = 0; idx < CacheSize; idx++)
  69. {
  70. Cache[idx].Age = 0;
  71. Cache[idx].SID = NULL;
  72. Cache[idx].SPN = NULL;
  73. }
  74. }
  75. inline
  76. SID_CACHE::~SID_CACHE ()
  77. {
  78. DWORD idx;
  79. for (idx = 0; idx < CacheSize; idx++)
  80. {
  81. delete [] Cache[idx].SID;
  82. delete [] Cache[idx].SPN;
  83. Cache[idx].Age = 0;
  84. Cache[idx].SID = NULL;
  85. Cache[idx].SPN = NULL;
  86. }
  87. }