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.

219 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. PerSeat.h
  5. Abstract:
  6. Author:
  7. Arthur Hanson (arth) Dec 07, 1994
  8. Environment:
  9. Revision History:
  10. Jeff Parham (jeffparh) 12-Jan-1996
  11. o Added support for maintaining the SUITE_USE flag when adding
  12. users to the AddCache.
  13. o Exported function prototype for MappingLicenseListFree().
  14. --*/
  15. #ifndef _LLS_PERSEAT_H
  16. #define _LLS_PERSEAT_H
  17. #include "llsrtl.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #define DATA_TYPE_USERNAME 0
  22. #define DATA_TYPE_SID 1
  23. #define MAX_ACCESS_COUNT 0xFFFFFFF
  24. /////////////////////////////////////////////////////////////////////////
  25. //
  26. // Add cache is here as add records need exclusive access to the user table.
  27. // Since we may have alot of read requests comming in at once, we don't want
  28. // to hold up our reply waiting for the exclusive access to be granted, so
  29. // we just dump it onto the add cache (queue) and continue on.
  30. //
  31. // This is even more important with outgoing replication going on as we can
  32. // have shared access lock on the table for awhile.
  33. //
  34. // Incomming replication just bundles up the data and sticks it on the Add
  35. // Cache to be processed like normal requests.
  36. //
  37. struct _ADD_CACHE;
  38. typedef struct _ADD_CACHE {
  39. struct _ADD_CACHE *prev;
  40. ULONG DataType;
  41. ULONG DataLength;
  42. PVOID Data;
  43. PMASTER_SERVICE_RECORD Service;
  44. ULONG AccessCount;
  45. DWORD LastAccess;
  46. DWORD Flags;
  47. } ADD_CACHE, *PADD_CACHE;
  48. /////////////////////////////////////////////////////////////////////////
  49. //
  50. // These records are for storing the actual user-useage information.
  51. //
  52. typedef struct _USER_LICENSE_RECORD {
  53. DWORD Flags;
  54. PMASTER_SERVICE_ROOT Family;
  55. ULONG RefCount;
  56. //
  57. // Version of product License applies to
  58. PMASTER_SERVICE_RECORD Service;
  59. ULONG LicensesNeeded;
  60. } USER_LICENSE_RECORD, *PUSER_LICENSE_RECORD;
  61. typedef struct _SVC_RECORD {
  62. //
  63. // Actual service this is for
  64. //
  65. PMASTER_SERVICE_RECORD Service;
  66. //
  67. // What license we took - The product may be SQL 3.0, but in determining
  68. // the license we might have grabbed a SQL 4.0 license...
  69. //
  70. PUSER_LICENSE_RECORD License;
  71. ULONG AccessCount;
  72. DWORD LastAccess;
  73. ULONG Suite;
  74. DWORD Flags;
  75. } SVC_RECORD, *PSVC_RECORD;
  76. typedef struct _USER_RECORD {
  77. ULONG IDSize;
  78. PVOID UserID;
  79. //
  80. // Pointer to mapping to use.
  81. //
  82. PMAPPING_RECORD Mapping;
  83. //
  84. // Flags is mostly used right now for marking records to be deleted and
  85. // if backoffice has been set.
  86. //
  87. DWORD Flags;
  88. //
  89. // How many products are licensed vs unlicensed
  90. //
  91. ULONG LicensedProducts;
  92. //
  93. // Date when last replicated. Note: For SID records this is a pointer
  94. // into the USER_RECORD for the appropriate user.
  95. //
  96. ULONG_PTR LastReplicated;
  97. //
  98. // Keep only a critical section lock, and not RTL_RESOURCE (for read/write
  99. // locks). All updates of existing services (most common case by far) will
  100. // be very quick, so exclusive access isn't that bad. RTL_RESOURCE also
  101. // would make our table size increase dramatically and add too much extra
  102. // processing.
  103. //
  104. RTL_CRITICAL_SECTION ServiceTableLock;
  105. //
  106. // Service table is a linear buffer, we use the service number to access
  107. // into this buffer.
  108. //
  109. ULONG ServiceTableSize;
  110. // Stuff per service - linear buffer...
  111. PSVC_RECORD Services;
  112. //
  113. // Licenses the user is using
  114. //
  115. ULONG LicenseListSize;
  116. PUSER_LICENSE_RECORD *LicenseList;
  117. } USER_RECORD, *PUSER_RECORD;
  118. /////////////////////////////////////////////////////////////////////////
  119. /////////////////////////////////////////////////////////////////////////
  120. /////////////////////////////////////////////////////////////////////////
  121. extern ULONG UserListNumEntries;
  122. extern LLS_GENERIC_TABLE UserList;
  123. extern RTL_RESOURCE UserListLock;
  124. //
  125. // The AddCache itself, a critical section to protect access to it and an
  126. // event to signal the server when there are items on it that need to be
  127. // processed.
  128. //
  129. extern PADD_CACHE AddCache;
  130. extern ULONG AddCacheSize;
  131. extern RTL_CRITICAL_SECTION AddCacheLock;
  132. extern HANDLE LLSAddCacheEvent;
  133. extern DWORD LastUsedTime;
  134. extern BOOL UsersDeleted;
  135. /////////////////////////////////////////////////////////////////////////
  136. /////////////////////////////////////////////////////////////////////////
  137. /////////////////////////////////////////////////////////////////////////
  138. PSVC_RECORD SvcListFind( LPTSTR DisplayName, PSVC_RECORD ServiceList, ULONG NumTableEntries );
  139. NTSTATUS SvcListDelete( LPTSTR UserName, LPTSTR ServiceName );
  140. VOID SvcListLicenseFree( PUSER_RECORD pUser );
  141. VOID SvcListLicenseUpdate( PUSER_RECORD pUser );
  142. NTSTATUS UserListInit();
  143. VOID UserListUpdate( ULONG DataType, PVOID Data, PSERVICE_RECORD Service );
  144. PUSER_RECORD UserListFind( LPTSTR UserName );
  145. VOID UserBackOfficeCheck( PUSER_RECORD pUser );
  146. VOID UserListLicenseDelete( PMASTER_SERVICE_RECORD Service, LONG Quantity );
  147. VOID UserLicenseListFree ( PUSER_RECORD pUser );
  148. VOID UserMappingAdd ( PMAPPING_RECORD Mapping, PUSER_RECORD pUser );
  149. VOID FamilyLicenseUpdate ( PMASTER_SERVICE_ROOT Family );
  150. VOID SvcLicenseUpdate( PUSER_RECORD pUser, PSVC_RECORD Svc );
  151. VOID MappingLicenseListFree ( PMAPPING_RECORD Mapping );
  152. VOID MappingLicenseUpdate ( PMAPPING_RECORD Mapping, BOOL ReSynch );
  153. /////////////////////////////////////////////////////////////////////////
  154. #if DBG
  155. VOID AddCacheDebugDump( );
  156. VOID UserListDebugDump( );
  157. VOID UserListDebugInfoDump( PVOID Data );
  158. VOID UserListDebugFlush( );
  159. VOID SidListDebugDump( );
  160. VOID SidListDebugInfoDump( PVOID Data );
  161. VOID SidListDebugFlush( );
  162. #endif
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif