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.

472 lines
16 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File : srvdef.h
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #ifndef __TLSERVER_DEF_H__
  13. #define __TLSERVER_DEF_H__
  14. #include "ntverp.h"
  15. //----------------------------------------------
  16. // #define TLS_CURRENT_VERSION (MAKELONG(0, HIBYTE(VER_PRODUCTVERSION_W)))
  17. //
  18. // Bit 31 - 1 if enterprise server, 0 if domain/workgroup license server
  19. // Bit 30 - 1 if enforce license server, 0 if non-enforce.
  20. // Bit 29 - 1 if RTM version, 0 if beta
  21. //
  22. #if defined(ENFORCE_LICENSING)
  23. #define TLS_ENFORCE_VERSION 0x4000
  24. #else
  25. #define TLS_ENFORCE_VERSION 0x0000
  26. #endif
  27. #define TLS_RTM_VERSION 0x2000
  28. //-----------------------------------------------------------------
  29. //
  30. // License Server Version
  31. //
  32. // 5.0 W2K license server version.
  33. // 5.1 Add LKP replication.
  34. // 5.2 Post W2K Beta 3 check in.
  35. // 5.3 Turn on enforce build, TLSAPI enumeration will skip 5.2 non-enforce
  36. // 5.4 Depends on platform challenge response from client, issue long or short cert cain
  37. //
  38. #define TLS_MINOR_VERSION 0x04
  39. #define TLS_CURRENT_VERSION (MAKELONG(MAKEWORD(TLS_MINOR_VERSION, HIBYTE(VER_PRODUCTVERSION_W)), TLS_ENFORCE_VERSION))
  40. #define TLS_CURRENT_VERSION_RTM (MAKELONG(MAKEWORD(TLS_MINOR_VERSION, HIBYTE(VER_PRODUCTVERSION_W)), TLS_ENFORCE_VERSION | TLS_RTM_VERSION))
  41. #define GET_SERVER_MAJOR_VERSION(version) HIBYTE(LOWORD(version))
  42. #define GET_SERVER_MINOR_VERSION(version) LOBYTE(LOWORD(version))
  43. #define IS_ENTERPRISE_SERVER(version) ((version & TLS_VERSION_ENTERPRISE_BIT) > 0)
  44. #define IS_ENFORCE_SERVER(version) \
  45. ((version & 0x40000000) > 0)
  46. //----------------------------------------------
  47. //
  48. // Service Manager Error Code
  49. //
  50. //----------------------------------------------
  51. //#define TLS_E_SERVICE_STARTUP_GENERAL 0x1
  52. //#define TLS_E_SERVICE_STARTUP_CREATE_THREAD 0x2
  53. //#define TLS_E_SERVICE_STARTUP_REPORT_SCM 0x3
  54. //#define TLS_E_SERVICE_STARTUP_RPC_THREAD_ERROR 0x4
  55. //#define TLS_E_SERVICE_STARTUP_INIT_THREAD_ERROR 0x5
  56. //#define TLS_E_SERVICE_STARTUP_POST_INIT 0x6
  57. //#define TLS_E_SERVICE_RPC_LISTEN 0x7
  58. //#define TLS_E_SERVICE_LOAD_POLICY 0x8
  59. //#define TLS_I_SERVICE_WARNING 0x9
  60. #define SET_JB_ERROR(err) (TLS_E_JB_BASE | abs(err))
  61. #define IS_JB_ERROR(err) ((err & (FACILITY_JETBLUE_BASE << 16)))
  62. // JetBlue error code are in negative
  63. #define GET_JB_ERROR_CODE(err) (-((LONG)(err & ~(FACILITY_JETBLUE_BASE << 16))))
  64. #ifndef USE_MULTIPLE_WORKSPACE
  65. #define ALLOCATEDBHANDLE(stmt, timeout) \
  66. AcquireRPCExclusiveLock(timeout) \
  67. #define FREEDBHANDLE(stmt) \
  68. g_DbWorkSpace->Cleanup(); \
  69. ReleaseRPCExclusiveLock()
  70. #define BEGIN_TRANSACTION(stmt) \
  71. g_DbWorkSpace->BeginTransaction();
  72. #define COMMIT_TRANSACTION(stmt) \
  73. g_DbWorkSpace->CommitTransaction();
  74. #define ROLLBACK_TRANSACTION(stmt) \
  75. g_DbWorkSpace->RollbackTransaction();
  76. #define CLEANUPSTMT \
  77. g_DbWorkSpace->Cleanup()
  78. #define USEHANDLE(stmt) \
  79. g_DbWorkSpace
  80. #define RPCCALL_LOCK(timeout) \
  81. AcquireRPCExclusiveLock(timeout)
  82. #define RPCCALL_UNLOCK \
  83. ReleaseRPCExclusiveLock()
  84. #else
  85. //
  86. // Not tested yet!!!
  87. //
  88. #define ALLOCATEDBHANDLE(pStmt, timeout) \
  89. pStmt = AllocateWorkSpace(timeout)
  90. #define FREEDBHANDLE(pStmt) \
  91. pStmt->Cleanup(); \
  92. ReleaseWorkSpace(pStmt);
  93. #define BEGIN_TRANSACTION(pStmt) \
  94. pStmt->BeginTransaction();
  95. #define COMMIT_TRANSACTION(pStmt) \
  96. pStmt->CommitTransaction();
  97. #define ROLLBACK_TRANSACTION(pStmt) \
  98. pStmt->RollbackTransaction();
  99. #define CLEANUPSTMT \
  100. pStmt->Cleanup()
  101. #define USEHANDLE(pStmt) \
  102. pStmt
  103. #define RPCCALL_LOCK(timeout) \
  104. AcquireRPCExclusiveLock(timeout)
  105. #define RPCCALL_UNLOCK \
  106. ReleaseRPCExclusiveLock()
  107. #endif
  108. //----------------------------------------------------------------------
  109. //
  110. //
  111. #ifndef SPC_CERT_EXTENSIONS_OBJID
  112. #define SPC_CERT_EXTENSIONS_OBJID "1.3.6.1.4.1.311.2.1.14"
  113. #endif
  114. //---------------------------------------------------------------------------
  115. // Server specified Registry Entry
  116. //
  117. #define LSERVER_REGISTRY_BASE _TEXT("SYSTEM\\CurrentControlSet\\Services\\")
  118. #define LSERVER_PARAMETERS _TEXT("Parameters")
  119. #define LSERVER_PARAMETERS_SCOPE _TEXT("Scope")
  120. #define LSERVER_PARAMETERS_DBPATH _TEXT("DBPath") // database file
  121. #define LSERVER_PARAMETERS_DBFILE _TEXT("DBFile") // database file
  122. #define LSERVER_PARAMETERS_USER _TEXT("User")
  123. #define LSERVER_PARAMETERS_PWD _TEXT("Pwd")
  124. #define LSERVER_PARAMETERS_LOGLEVEL _TEXT("Log Level")
  125. #define LSERVER_PARAMETERS_CONSOLE _TEXT("Console")
  126. #define LSERVER_PARAMETERS_ROLE _TEXT("Role")
  127. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE _TEXT("MaxCacheSize")
  128. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH _TEXT("StartFlushThreshold")
  129. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH _TEXT("StopFlushThreshold")
  130. #define LSERVER_PARAMETERS_ESENTMAXVERPAGES _TEXT("MaxVerPages")
  131. #define LSERVER_PARAMETERS_LEASE_MIN _TEXT("LeaseMinimum")
  132. #define LSERVER_PARAMETERS_LEASE_RANGE _TEXT("LeaseRange")
  133. #define LSERVER_PARAMETERS_LEASE_LEEWAY _TEXT("LeaseLeeway")
  134. #define LSERVER_PARAMETERS_EXPIRE_THREAD_SLEEP _TEXT("ExpireThreadSleep")
  135. //
  136. // JET_paramCacheSizeMax is expressed in pages,
  137. // default 4K per page.
  138. //
  139. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE_DEFAULT 256
  140. //#define LSERVER_PARAMETERS_ESENTMINCACHESIZE_DEFAULT 16
  141. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH_DEFAULT 100
  142. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH_DEFAULT 200
  143. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE_MAX 512
  144. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH_MAX 100
  145. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH_MAX 400
  146. #define LSERVER_PARAMETERS_ESENTMAXVERPAGES_MAX 2048
  147. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE_MIN 64
  148. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH_MIN 16
  149. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH_MIN 32
  150. #define LSERVER_PARAMETERS_ESENTMAXVERPAGES_MIN 256
  151. //
  152. // MaxCacheSize is set to 0xFFFFFFFF, we just let ESENT pick its number
  153. //
  154. #define LSERVER_PARAMETERS_USE_ESENTDEFAULT 0xFFFFFFFF
  155. #define LSERVER_PARAMETERS_KEY \
  156. LSERVER_REGISTRY_BASE _TEXT(SZSERVICENAME) _TEXT("\\") LSERVER_PARAMETERS
  157. #define LSERVER_SIGNATURE_CERTIFICATE_KEY _TEXT("Signature Certificate")
  158. #define LSERVER_EXCHANGE_CERTIFICATE_KEY _TEXT("Exchange Certificate")
  159. #define TLSERVER_SERVER_ID_VERSION 0x00010001
  160. typedef struct _TlsLsaServerId {
  161. DWORD dwVersion; // structure version
  162. DWORD dwUniqueId; // TLServer 5 digit unique ID
  163. DWORD dwServerPid; // TLServer PID
  164. DWORD dwServerSPK; // TLServer's SPK if any.
  165. DWORD dwExtensions; // Size of encoded certificate entension.
  166. BYTE pbVariableStart[1]; // UniqueId follow by ServerPid then ServerSPK.
  167. } TLSLSASERVERID, *PTLSLSASERVERID, *LPTLSLSASERVERID;
  168. //----------------------------------------------------------------------
  169. //
  170. // Registry key for License Server certificate issued by CA
  171. //
  172. //----------------------------------------------------------------------
  173. #define LSERVER_SOFTWARE_REGBASE \
  174. _TEXT("SOFTWARE\\Microsoft\\") _TEXT(SZSERVICENAME)
  175. #define LSERVER_CERTIFICATE_STORE _TEXT("Certificates")
  176. #define LSERVER_CERTIFICATE_STORE_BACKUP1 _TEXT("Certificates.000")
  177. #define LSERVER_CERTIFICATE_STORE_BACKUP2 _TEXT("Certificates.001")
  178. #define LSERVER_SELFSIGN_CERTIFICATE_REGKEY \
  179. LSERVER_REGISTRY_BASE _TEXT(SZSERVICENAME) _TEXT("\\") LSERVER_SECRET
  180. #define LSERVER_SERVER_CERTIFICATE_REGKEY \
  181. LSERVER_SOFTWARE_REGBASE _TEXT("\\") LSERVER_CERTIFICATE_STORE
  182. #define LSERVER_SERVER_CERTIFICATE_REGKEY_BACKUP1 \
  183. LSERVER_PARAMETERS_KEY _TEXT("\\") LSERVER_CERTIFICATE_STORE_BACKUP1
  184. #define LSERVER_SERVER_CERTIFICATE_REGKEY_BACKUP2 \
  185. LSERVER_PARAMETERS_KEY _TEXT("\\") LSERVER_CERTIFICATE_STORE_BACKUP2
  186. #define LSERVER_PARAMETERS_GRACEPERIOD _TEXT("GracePeriod")
  187. #define LSERVER_PARAMETERS_LOWLICENSEWARNING _TEXT("Low License Warning")
  188. #define LSERVER_PARAMETERS_ISSUETEMPLICENSE _TEXT("IssueTemporaryLicenses")
  189. #define LSERVER_PARAMETERS_WORKINTERVAL _TEXT("DefaultJobInterval")
  190. #define LSERVER_PARAMETERS_RETRYTIMES _TEXT("DefaultJobRetryTimes")
  191. #define LSERVER_PARAMETERS_WORKRESTART _TEXT("DefaultJobRestartTime")
  192. #define LSERVER_CLIENT_CERTIFICATE_ISSUER _TEXT("Parm0")
  193. #define LSERVER_SIGNATURE_CERT_KEY _TEXT("Parm1")
  194. #define LSERVER_EXCHANGE_CERT_KEY _TEXT("Parm2")
  195. #define LSERVER_SIGNATURE_CERTCHAIN_KEY _TEXT("Parm3")
  196. #define LSERVER_POLICY_REGKEY _TEXT("Policy")
  197. #define LSERVER_POLICY_DLLPATH _TEXT("Dll")
  198. #define LSERVER_POLICY_DLLFLAG _TEXT("Flags")
  199. #define LSERVER_POLICY_REGBASE \
  200. LSERVER_SOFTWARE_REGBASE _TEXT("\\") LSERVER_POLICY_REGKEY
  201. #define TLS_ERROR(dwErrCode) ((dwErrCode & 0xC0000000) == 0xC0000000)
  202. //---------------------------------------------------------------------
  203. #define MAXTCPNAME MAXGETHOSTSTRUCT
  204. //------------------------------------------------------------------------------------------------
  205. // Hydra Specific Product SKU
  206. //
  207. // 236-4.00-S Windows NT Workstation 4.0 Full Version Non Windows and Non NT Client
  208. // 236-4.00-VU Windows NT Workstation 4.0 Version Upgrade Windows NT 3.51 Client
  209. // 236-4.00-EX Existing Windows NT Workstation 4.0 License Windows NT 4.0 and 5.0 Client
  210. //
  211. #define HYDRA_PRODUCTID_SKU "236"
  212. #define HYDRA_FULLVERSION_POSTFIX "S"
  213. #define HYDRA_UPGRADE_POSTFIX "VU"
  214. #define HYDRA_EXISTING "EX"
  215. #define HYDRAPRODUCT_FULLVERSION_SKU _TEXT("236-4.00-S")
  216. #define HYDRAPRODUCT_UPGRADE_SKU _TEXT("236-4.00-VU")
  217. #define HYDRAPRODUCT_EXISTING_SKU _TEXT("236-4.00-EX")
  218. //
  219. // 236 Product ID
  220. //
  221. #define PLATFORMID_UPGRADE 1
  222. #define PLATFORMID_FREE 2
  223. #define PLATFORMID_OTHERS 0xFF
  224. #define TERMSERV_PRODUCTID_SKU _TEXT("A02")
  225. #define TERMSERV_PRODUCTID_INTERNET_SKU _TEXT("B96")
  226. #define TERMSERV_PRODUCTID_CONCURRENT_SKU _TEXT("C50")
  227. #define TERMSERV_FULLVERSION_TYPE _TEXT("S")
  228. #define TERMSERV_FREE_TYPE _TEXT("EX")
  229. #define TERMSERV_INTERNET_TYPE _TEXT("I")
  230. #define TERMSERV_CONCURRENT_TYPE _TEXT("C")
  231. #define TERMSERV_PRODUCTID_SCAN_FORMAT _TEXT("%3s-%ld.%02ld-%9s")
  232. #define MAX_TERMSRV_PRODUCTID LSERVER_MAX_STRING_SIZE
  233. #define MAX_SKU_PREFIX 10
  234. #define MAX_SKU_POSTFIX 10
  235. //
  236. // Following two are info. for special key pack that
  237. // will be used for issuing certificate to hydra server.
  238. //
  239. #define HYDRAPRODUCT_HS_CERTIFICATE_SKU \
  240. _TEXT("3d267954-eeb7-11d1-b94e-00c04fa3080d")
  241. #define HYDRAPRODUCT_HS_CERTIFICATE_KEYPACKID \
  242. _TEXT("3d267954-eeb7-11d1-b94e-00c04fa3080d")
  243. #define HYDRACERT_PRODUCT_VERSION 0x0001000
  244. // Windows NT Upgrade=1, Windows NT Free=2, Others=3
  245. #define CLIENT_PLATFORMID_WINDOWS_NT_UPGRADE 1
  246. #define CLIENT_PLATFORMID_WINDOWS_NT_FREE 2
  247. #define CLIENT_PLATFORMID_OTHERS 3
  248. //---------------------------------------------------------------------------
  249. //
  250. // Common Define
  251. //
  252. #define LICENSE_MIN_MATCH 3
  253. #define RPC_MINIMUMCALLTHREADS 1
  254. #define RPC_MAXIMUMCALLTHREADS RPC_C_LISTEN_MAX_CALLS_DEFAULT
  255. #define SC_WAITHINT 3000
  256. #define ODBC_MAX_SQL_STRING 8196 // max. sql string
  257. #define DEFAULT_CONNECTION_TIMEOUT 5*60*1000 // odbc.h
  258. #define DB_ENUM_WAITTIMEOUT 10*1000 // 10 second time out
  259. // for enumeration handle
  260. #define MAX_LICENSE_SIZE 4096
  261. #define GRACE_PERIOD 90 // default to 90 days
  262. #define DEFAULT_DB_CONNECTIONS 4
  263. #define LSERVER_PARAMETERS_DBTIMEOUT _TEXT("Db ConnectionTimeout")
  264. #define LSERVER_PARAMETERS_EDBTIMEOUT _TEXT("Enum DbConnection Timeout")
  265. #define LSERVER_PARAMETERS_MAXDBHANDLES _TEXT("Max DB Handles")
  266. #define DB_MAX_CONNECTIONS 20
  267. #define DB_MIN_HANDLE_NEEDED 3 // keypack enumeration uses two handle
  268. // need odd number to prevent deadlock
  269. //---------------------------------------------------------------------------
  270. //
  271. // draft-ietf-pkix-ipki-part1-06.txt section 4.1.2.5.1
  272. // where year is greater or equal to 50, the year shall be interpreted as 19YY; and
  273. // where year is less than 50, the year shall be interpreted as 20YY
  274. //
  275. #define PERMANENT_CERT_EXPIRE_DATE 2049
  276. //---------------------------------------------------------------------------
  277. //
  278. // Internal specific not export to RPC
  279. //
  280. #define LSKEYPACKSTATUS_DELETE 0xF
  281. #define LSLICENSESTATUS_DELETE 0xF
  282. #define LSKEYPACKSTATUS_BETA 0x10
  283. #define LSKEYPACKSTATUS_HIDDEN 0x20
  284. #define LSKEYPACKSTATUS_LOCAL 0x40
  285. #define LSKEYPACKSTATUS_REMOTE 0x80
  286. #define LSKEYPACKSTATUS_RESERVED 0xF0
  287. #define LSKEYPACK_REMOTE_TYPE 0x80
  288. #define LSKEYPACK_LOCAL_TYPE 0x40
  289. #define LSKEYPACK_HIDDEN_TYPE 0x20
  290. #define LSKEYPACK_RESERVED_TYPE 0xF0
  291. #define LSKEYPACK_PLATFORM_REMOTE 0x80000000
  292. //----------------------------------------------------------------------------
  293. //
  294. // KeyPackDesc Table specific
  295. //
  296. #define KEYPACKDESC_SEARCH_NONE 0x00000000
  297. #define KEYPACKDESC_SEARCH_ALL 0xFFFFFFFF
  298. #define KEYPACKDESC_SET_ADD_ENTRY 0x00010000
  299. #define KEYPACKDESC_SET_DELETE_ENTRY 0x00020000
  300. //---------------------------------------------------------------------------
  301. #ifndef AllocateMemory
  302. #define AllocateMemory(size) \
  303. LocalAlloc(LPTR, size)
  304. #endif
  305. #ifndef FreeMemory
  306. #define FreeMemory(ptr) \
  307. if(ptr) \
  308. { \
  309. LocalFree(ptr); \
  310. ptr=NULL; \
  311. }
  312. #endif
  313. #ifndef ReallocateMemory
  314. #define ReallocateMemory(ptr, size) \
  315. LocalReAlloc(ptr, size, LMEM_ZEROINIT)
  316. #endif
  317. #ifndef SAFESTRCPY
  318. #define SAFESTRCPY(dest, source) \
  319. _tcsncpy(dest, source, min(_tcslen(source), sizeof(dest)/sizeof(TCHAR))); \
  320. dest[min(_tcslen(source), (sizeof(dest)/sizeof(TCHAR) -1))] = _TEXT('\0');
  321. #endif
  322. //---------------------------------------------------------------------------
  323. //
  324. // Return code from LSWaitForService()
  325. //
  326. #define WAIT_SERVICE_UNKNOWN 0
  327. #define WAIT_SERVICE_ERROR 1
  328. #define WAIT_SERVICE_ALREADY_RUNNING 2
  329. #define WAIT_SERVICE_MANUALLY_STARTED 3
  330. #define WAIT_SERVICE_NOT_EXIST 4
  331. #define WAIT_SERVICE_DISABLED 5
  332. #define WAIT_SERVICE_READY 6
  333. #define LICENSE_TABLE_EXTERN_SEARCH_MASK \
  334. (LSLICENSE_SEARCH_LICENSEID | LSLICENSE_SEARCH_KEYPACKID | \
  335. LSLICENSE_SEARCH_MACHINENAME | \
  336. LSLICENSE_SEARCH_USERNAME | \
  337. LSLICENSE_SEARCH_ISSUEDATE | LSLICENSE_SEARCH_NUMLICENSES | \
  338. LSLICENSE_SEARCH_EXPIREDATE | LSLICENSE_EXSEARCH_LICENSESTATUS)
  339. //
  340. // The original style permanent license will never expire. The leased license
  341. // will expire in a random period between 52 and 89 days.
  342. //
  343. #define PERMANENT_LICENSE_EXPIRE_DATE INT_MAX
  344. //#define PERMANENT_LICENSE_LEASE_EXPIRE_MIN (3*60) // testing: 3 min
  345. //#define PERMANENT_LICENSE_LEASE_EXPIRE_RANGE (60) // testing: 1 min
  346. //#define EXPIRE_THREAD_SLEEP_TIME (1000*60*5) /* five min */
  347. #define PERMANENT_LICENSE_LEASE_EXPIRE_MIN (52 * 24 * 60 * 60)
  348. #define PERMANENT_LICENSE_LEASE_EXPIRE_RANGE (37 * 24 * 60 * 60)
  349. #define EXPIRE_THREAD_SLEEP_TIME (1000*60*60*24) /* one day */
  350. #define TLSERVER_CHALLENGE_CONTEXT 0xFFFFFFFF
  351. #define TLSERVER_ENTERPRISE_SERVER 0x00000001
  352. #define DEFAULT_CSP MS_DEF_PROV
  353. #define PROVIDER_TYPE PROV_RSA_FULL
  354. #define CRYPTOINIT_ALREADY_EXIST 0x00000000
  355. #define CRYPTOINIT_CREATE_CONTAINER 0x00000001
  356. #define CRYPTOINIT_CREATE_SIGNKEY 0x00000002
  357. #define CRYPTOINIT_CREATE_EXCHKEY 0x00000004
  358. #define TLSBACKUP_EXPORT_DIR _TEXT("Export")
  359. #endif