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.

359 lines
10 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. sceutil.h
  5. Abstract:
  6. This module defines the data structures and function prototypes
  7. shared by both SCE client and SCE server
  8. Author:
  9. Jin Huang (jinhuang) 23-Jan-1998
  10. Revision History:
  11. jinhuang (splitted from scep.h)
  12. --*/
  13. #ifndef _sceutil_
  14. #define _sceutil_
  15. #include <ntlsa.h>
  16. #include <cfgmgr32.h>
  17. typedef struct _SCE_USER_PRIV_LOOKUP {
  18. UINT Value;
  19. PWSTR Name;
  20. }SCE_USER_PRIV_LOOKUP;
  21. static SCE_USER_PRIV_LOOKUP SCE_Privileges[] = {
  22. {0, (PWSTR)SE_NETWORK_LOGON_NAME},
  23. // Access the computer from network
  24. {SE_TCB_PRIVILEGE, (PWSTR)SE_TCB_NAME},
  25. // Act as part of the operating System
  26. {SE_MACHINE_ACCOUNT_PRIVILEGE, (PWSTR)SE_MACHINE_ACCOUNT_NAME},
  27. // Add workstations to the domain
  28. {SE_BACKUP_PRIVILEGE, (PWSTR)SE_BACKUP_NAME},
  29. // Back up files and directories
  30. {SE_CHANGE_NOTIFY_PRIVILEGE, (PWSTR)SE_CHANGE_NOTIFY_NAME},
  31. // Bypass traverse checking
  32. {SE_SYSTEMTIME_PRIVILEGE, (PWSTR)SE_SYSTEMTIME_NAME},
  33. // Change the system time
  34. {SE_CREATE_PAGEFILE_PRIVILEGE, (PWSTR)SE_CREATE_PAGEFILE_NAME},
  35. // Create a pagefile
  36. {SE_CREATE_TOKEN_PRIVILEGE, (PWSTR)SE_CREATE_TOKEN_NAME},
  37. // Create a token object
  38. {SE_CREATE_PERMANENT_PRIVILEGE, (PWSTR)SE_CREATE_PERMANENT_NAME},
  39. // Create permanent shared objects
  40. {SE_DEBUG_PRIVILEGE, (PWSTR)SE_DEBUG_NAME},
  41. // Debug programs
  42. {SE_REMOTE_SHUTDOWN_PRIVILEGE, (PWSTR)SE_REMOTE_SHUTDOWN_NAME},
  43. // Force shutdown from a remote system
  44. {SE_AUDIT_PRIVILEGE, (PWSTR)SE_AUDIT_NAME},
  45. // Generate security audits
  46. {SE_INCREASE_QUOTA_PRIVILEGE, (PWSTR)SE_INCREASE_QUOTA_NAME},
  47. // Increase quotas
  48. {SE_INC_BASE_PRIORITY_PRIVILEGE,(PWSTR)SE_INC_BASE_PRIORITY_NAME},
  49. // Increase scheduling priority
  50. {SE_LOAD_DRIVER_PRIVILEGE, (PWSTR)SE_LOAD_DRIVER_NAME},
  51. // Load and unload device drivers
  52. {SE_LOCK_MEMORY_PRIVILEGE, (PWSTR)SE_LOCK_MEMORY_NAME},
  53. // Lock pages in memory
  54. {0, (PWSTR)SE_BATCH_LOGON_NAME},
  55. // Logon as a batch job
  56. {0, (PWSTR)SE_SERVICE_LOGON_NAME},
  57. // Logon as a service
  58. {0, (PWSTR)SE_INTERACTIVE_LOGON_NAME},
  59. // Logon locally
  60. {SE_SECURITY_PRIVILEGE, (PWSTR)SE_SECURITY_NAME},
  61. // Manage auditing and security log
  62. {SE_SYSTEM_ENVIRONMENT_PRIVILEGE, (PWSTR)SE_SYSTEM_ENVIRONMENT_NAME},
  63. // Modify firmware environment variables
  64. {SE_PROF_SINGLE_PROCESS_PRIVILEGE,(PWSTR)SE_PROF_SINGLE_PROCESS_NAME},
  65. // Profile single process
  66. {SE_SYSTEM_PROFILE_PRIVILEGE, (PWSTR)SE_SYSTEM_PROFILE_NAME},
  67. // Profile system performance
  68. {SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, (PWSTR)SE_ASSIGNPRIMARYTOKEN_NAME},
  69. // Replace a process-level token
  70. {SE_RESTORE_PRIVILEGE, (PWSTR)SE_RESTORE_NAME},
  71. // Restore files and directories
  72. {SE_SHUTDOWN_PRIVILEGE, (PWSTR)SE_SHUTDOWN_NAME},
  73. // Shut down the system
  74. {SE_TAKE_OWNERSHIP_PRIVILEGE, (PWSTR)SE_TAKE_OWNERSHIP_NAME},
  75. // Take ownership of files or other objects
  76. // {SE_UNSOLICITED_INPUT_PRIVILEGE,(PWSTR)SE_UNSOLICITED_INPUT_NAME},
  77. // Unsolicited Input is obsolete and unused
  78. {0, (PWSTR)SE_DENY_NETWORK_LOGON_NAME},
  79. // Deny access the computer from network
  80. {0, (PWSTR)SE_DENY_BATCH_LOGON_NAME},
  81. // Deny Logon as a batch job
  82. {0, (PWSTR)SE_DENY_SERVICE_LOGON_NAME},
  83. // Deny Logon as a service
  84. {0, (PWSTR)SE_DENY_INTERACTIVE_LOGON_NAME},
  85. // Deny logon locally
  86. {SE_UNDOCK_PRIVILEGE, (PWSTR)SE_UNDOCK_NAME},
  87. // Undock privilege
  88. {SE_SYNC_AGENT_PRIVILEGE, (PWSTR)SE_SYNC_AGENT_NAME},
  89. // Sync agent privilege
  90. {SE_ENABLE_DELEGATION_PRIVILEGE,(PWSTR)SE_ENABLE_DELEGATION_NAME},
  91. // enable delegation privilege
  92. {SE_MANAGE_VOLUME_PRIVILEGE, (PWSTR)SE_MANAGE_VOLUME_NAME},
  93. // (NTFS) Manage volume privilege
  94. {0, (PWSTR)SE_REMOTE_INTERACTIVE_LOGON_NAME},
  95. // (TS) logon locally from a TS session
  96. {0, (PWSTR)SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME}
  97. // (TS) deny logon locally from a TS session
  98. };
  99. typedef struct _SCE_TEMP_NODE_ {
  100. PWSTR Name;
  101. DWORD Len;
  102. BOOL bFree;
  103. } SCE_TEMP_NODE, *PSCE_TEMP_NODE;
  104. //
  105. // This structure is used to find well known name locally for performance.
  106. //
  107. typedef struct _WELL_KNOWN_NAME_LOOKUP {
  108. PWSTR StrSid;
  109. WCHAR Name[36];
  110. } WELL_KNOWN_NAME_LOOKUP, *PWELL_KNOWN_NAME_LOOKUP;
  111. #define TABLE_SIZE 33
  112. static WELL_KNOWN_NAME_LOOKUP NameTable[] = {
  113. //Universal well-known
  114. { L"S-1-1-0", L'\0' }, //Everyone
  115. //{ L"S-1-2-0", L'\0' }, //Local
  116. { L"S-1-3-0", L'\0' }, //Creator Owner
  117. { L"S-1-3-1", L'\0' }, //Creator Group
  118. { L"S-1-3-2", L'\0' }, //Creator Owner Server
  119. { L"S-1-3-3", L'\0' }, //Creator Group Server
  120. //NT well-known
  121. //{ L"S-1-5", L'\0' }, //NT Pseudo Domain
  122. { L"S-1-5-1", L'\0' }, //Dialup
  123. { L"S-1-5-2", L'\0' }, //Network
  124. { L"S-1-5-3", L'\0' }, //Batch
  125. { L"S-1-5-4", L'\0' }, //Interactive
  126. { L"S-1-5-6", L'\0' }, //Service
  127. { L"S-1-5-7", L'\0' }, //Anonymous Logon
  128. { L"S-1-5-8", L'\0' }, //Proxy
  129. { L"S-1-5-9", L'\0' }, //Enterprise Domain Controllers
  130. { L"S-1-5-10", L'\0' }, //Self
  131. { L"S-1-5-11", L'\0' }, //Authenticated Users
  132. { L"S-1-5-12", L'\0' }, //Restricted
  133. { L"S-1-5-13", L'\0' }, //Terminal Server User
  134. { L"S-1-5-18", L'\0' }, //Local system
  135. { L"S-1-5-19", L'\0' }, //Local Service
  136. { L"S-1-5-20", L'\0' }, //Network Service
  137. //Builtin
  138. { L"S-1-5-32-544", L'\0' }, //Administrtors
  139. { L"S-1-5-32-545", L'\0' }, //Users
  140. { L"S-1-5-32-546", L'\0' }, //Guests
  141. { L"S-1-5-32-547", L'\0' }, //Power Users
  142. { L"S-1-5-32-548", L'\0' }, //Account Operators
  143. { L"S-1-5-32-549", L'\0' }, //Server Operators
  144. { L"S-1-5-32-550", L'\0' }, //Print Operators
  145. { L"S-1-5-32-551", L'\0' }, //Backup Operators
  146. { L"S-1-5-32-552", L'\0' }, //Replicator
  147. { L"S-1-5-32-553", L'\0' }, //Ras Servers
  148. { L"S-1-5-32-554", L'\0' }, //PREW2KCOMPACCESS
  149. { L"S-1-5-32-555", L'\0' }, //Remote desktop users
  150. { L"S-1-5-32-556", L'\0' } // network configuraiton operators
  151. };
  152. //
  153. // Bit masks encoding rsop area information
  154. //
  155. #define SCE_RSOP_PASSWORD_INFO (0x1)
  156. #define SCE_RSOP_LOCKOUT_INFO (0x1 << 1)
  157. #define SCE_RSOP_LOGOFF_INFO (0x1 << 2)
  158. #define SCE_RSOP_ADMIN_INFO (0x1 << 3)
  159. #define SCE_RSOP_GUEST_INFO (0x1 << 4)
  160. #define SCE_RSOP_GROUP_INFO (0x1 << 5)
  161. #define SCE_RSOP_PRIVILEGE_INFO (0x1 << 6)
  162. #define SCE_RSOP_FILE_SECURITY_INFO (0x1 << 7)
  163. #define SCE_RSOP_REGISTRY_SECURITY_INFO (0x1 << 8)
  164. #define SCE_RSOP_AUDIT_LOG_MAXSIZE_INFO (0x1 << 9)
  165. #define SCE_RSOP_AUDIT_LOG_RETENTION_INFO (0x1 << 10)
  166. #define SCE_RSOP_AUDIT_LOG_GUEST_INFO (0x1 << 11)
  167. #define SCE_RSOP_AUDIT_EVENT_INFO (0x1 << 12)
  168. #define SCE_RSOP_KERBEROS_INFO (0x1 << 13)
  169. #define SCE_RSOP_REGISTRY_VALUE_INFO (0x1 << 14)
  170. #define SCE_RSOP_SERVICES_INFO (0x1 << 15)
  171. #define SCE_RSOP_FILE_SECURITY_INFO_CHILD (0x1 << 16)
  172. #define SCE_RSOP_REGISTRY_SECURITY_INFO_CHILD (0x1 << 17)
  173. #define SCE_RSOP_LSA_POLICY_INFO (0x1 << 18)
  174. #define SCE_RSOP_DISABLE_ADMIN_INFO (0x1 << 19)
  175. #define SCE_RSOP_DISABLE_GUEST_INFO (0x1 << 20)
  176. BOOL
  177. ScepInitNameTable();
  178. BOOL
  179. ScepLookupNameTable(
  180. IN PWSTR Name,
  181. OUT PWSTR *StrSid
  182. );
  183. INT
  184. ScepLookupPrivByName(
  185. IN PCWSTR Right
  186. );
  187. INT
  188. ScepLookupPrivByValue(
  189. IN DWORD Priv
  190. );
  191. SCESTATUS
  192. ScepGetProductType(
  193. OUT PSCE_SERVER_TYPE srvProduct
  194. );
  195. SCESTATUS
  196. ScepConvertMultiSzToDelim(
  197. IN PWSTR pValue,
  198. IN DWORD Len,
  199. IN WCHAR DelimFrom,
  200. IN WCHAR Delim
  201. );
  202. DWORD
  203. ScepAddTwoNamesToNameList(
  204. OUT PSCE_NAME_LIST *pNameList,
  205. IN BOOL bAddSeparator,
  206. IN PWSTR Name1,
  207. IN ULONG Length1,
  208. IN PWSTR Name2,
  209. IN ULONG Length2
  210. );
  211. NTSTATUS
  212. ScepDomainIdToSid(
  213. IN PSID DomainId,
  214. IN ULONG RelativeId,
  215. OUT PSID *Sid
  216. );
  217. DWORD
  218. ScepConvertSidToPrefixStringSid(
  219. IN PSID pSid,
  220. OUT PWSTR *StringSid
  221. );
  222. NTSTATUS
  223. ScepConvertSidToName(
  224. IN LSA_HANDLE LsaPolicy,
  225. IN PSID AccountSid,
  226. IN BOOL bFromDomain,
  227. OUT PWSTR *AccountName,
  228. OUT DWORD *Length OPTIONAL
  229. );
  230. NTSTATUS
  231. ScepConvertNameToSid(
  232. IN LSA_HANDLE LsaPolicy,
  233. IN PWSTR AccountName,
  234. OUT PSID *AccountSid
  235. );
  236. SCESTATUS
  237. ScepConvertNameToSidString(
  238. IN LSA_HANDLE LsaHandle,
  239. IN PWSTR Name,
  240. IN BOOL bAccountDomainOnly,
  241. OUT PWSTR *SidString,
  242. OUT DWORD *SidStrLen
  243. );
  244. SCESTATUS
  245. ScepLookupSidStringAndAddToNameList(
  246. IN LSA_HANDLE LsaHandle,
  247. IN OUT PSCE_NAME_LIST *pNameList,
  248. IN PWSTR LookupString,
  249. IN ULONG Len
  250. );
  251. SCESTATUS
  252. ScepLookupNameAndAddToSidStringList(
  253. IN LSA_HANDLE LsaHandle,
  254. IN OUT PSCE_NAME_LIST *pNameList,
  255. IN PWSTR LookupString,
  256. IN ULONG Len
  257. );
  258. NTSTATUS
  259. ScepOpenLsaPolicy(
  260. IN ACCESS_MASK access,
  261. OUT PLSA_HANDLE pPolicyHandle,
  262. IN BOOL bDoNotNotify
  263. );
  264. BOOL
  265. ScepIsSidFromAccountDomain(
  266. IN PSID pSid
  267. );
  268. BOOL
  269. SetupINFAsUCS2(
  270. IN LPCTSTR szName
  271. );
  272. WCHAR *
  273. ScepStripPrefix(
  274. IN LPTSTR pwszPath
  275. );
  276. DWORD
  277. ScepGenerateGuid(
  278. OUT PWSTR *ppwszGuid
  279. );
  280. SCESTATUS
  281. SceInfpGetPrivileges(
  282. IN HINF hInf,
  283. IN BOOL bLookupAccount,
  284. OUT PSCE_PRIVILEGE_ASSIGNMENT *pPrivileges,
  285. OUT PSCE_ERROR_LOG_INFO *Errlog OPTIONAL
  286. );
  287. DWORD
  288. ScepQueryAndAddService(
  289. IN SC_HANDLE hScManager,
  290. IN LPWSTR lpServiceName,
  291. IN LPWSTR lpDisplayName,
  292. OUT PSCE_SERVICES *pServiceList
  293. );
  294. NTSTATUS
  295. ScepIsSystemContext(
  296. IN HANDLE hUserToken,
  297. OUT BOOL *pbSystem
  298. );
  299. BOOL
  300. IsNT5();
  301. DWORD
  302. ScepVerifyTemplateName(
  303. IN PWSTR InfTemplateName,
  304. OUT PSCE_ERROR_LOG_INFO *pErrlog OPTIONAL
  305. );
  306. NTSTATUS
  307. ScepLsaLookupNames2(
  308. IN LSA_HANDLE PolicyHandle,
  309. IN ULONG Flags,
  310. IN PWSTR pszAccountName,
  311. OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
  312. OUT PLSA_TRANSLATED_SID2 *Sids
  313. );
  314. #endif