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.

313 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. Helper.h
  5. Abstract:
  6. Funtion prototype.
  7. Author:
  8. HueiWang 2/17/2000
  9. --*/
  10. #ifndef __HELPER_H__
  11. #define __HELPER_H__
  12. #include <windows.h>
  13. #define MAX_ACCDESCRIPTION_LENGTH 256
  14. #define MAX_HELPACCOUNT_NAME 256
  15. #ifndef __WIN9XBUILD__
  16. #define MAX_HELPACCOUNT_PASSWORD LM20_PWLEN // from lmcons.h
  17. #else
  18. // keep same max. password length same as NT
  19. #define MAX_HELPACCOUNT_PASSWORD 14
  20. #endif
  21. typedef HRESULT (WINAPI* RegEnumKeyCallback)(
  22. IN HKEY hKey,
  23. IN LPTSTR pszKeyName,
  24. IN HANDLE userData
  25. );
  26. #ifndef __WIN9XBUILD__
  27. #include <ntsecapi.h>
  28. #endif
  29. #ifdef __cplusplus
  30. extern "C"{
  31. #endif
  32. DWORD
  33. GenerateRandomString(
  34. IN DWORD dwSizeRandomSeed,
  35. IN OUT LPTSTR* pszRandomString
  36. );
  37. DWORD
  38. GenerateRandomBytes(
  39. IN DWORD dwSize,
  40. IN OUT LPBYTE pbBuffer
  41. );
  42. void
  43. UnixTimeToFileTime(
  44. time_t t,
  45. LPFILETIME pft
  46. );
  47. long
  48. GetUserTSLogonId();
  49. //
  50. // create a random password, buffer must
  51. // be at least MAX_HELPACCOUNT_PASSWORD+1
  52. DWORD
  53. CreatePassword(
  54. TCHAR *pszPassword
  55. );
  56. DWORD
  57. RegEnumSubKeys(
  58. IN HKEY hKey,
  59. IN LPCTSTR pszSubKey,
  60. IN RegEnumKeyCallback pFunc,
  61. IN HANDLE userData
  62. );
  63. DWORD
  64. RegDelKey(
  65. IN HKEY hRegKey,
  66. IN LPCTSTR pszSubKey
  67. );
  68. DWORD
  69. GetUserSid(
  70. PBYTE* ppbSid,
  71. DWORD* pcbSid
  72. );
  73. HRESULT
  74. GetUserSidString(
  75. OUT CComBSTR& bstrSid
  76. );
  77. #ifndef __WIN9XBUILD__
  78. BOOL
  79. MyMkTime(
  80. IN SYSTEMTIME* pSysTime,
  81. OUT FILETIME* pft
  82. );
  83. BOOL
  84. IsPersonalOrProMachine();
  85. //
  86. // Check if a user is in a local group
  87. //
  88. DWORD
  89. IsUserInLocalGroup(
  90. IN PBYTE pbUserSid,
  91. IN LPCTSTR pszLocalGroup,
  92. OUT BOOL* pbInGroup
  93. );
  94. //
  95. // Create a local account
  96. //
  97. DWORD
  98. CreateLocalAccount(
  99. IN LPWSTR pszUserName,
  100. IN LPWSTR pszUserPwd,
  101. IN LPWSTR pszUserFullName,
  102. IN LPWSTR pszUserDesc,
  103. IN LPWSTR pszGroupName,
  104. IN LPWSTR pszScript,
  105. OUT BOOL* pbAccountExists
  106. );
  107. //
  108. // Check if a user account is enabled.
  109. //
  110. DWORD
  111. IsLocalAccountEnabled(
  112. IN LPWSTR pszUserName,
  113. IN BOOL* pEnabled
  114. );
  115. //
  116. // Rename local account
  117. //
  118. DWORD
  119. RenameLocalAccount(
  120. IN LPWSTR pszOrgName,
  121. IN LPWSTR pszNewName
  122. );
  123. DWORD
  124. UpdateLocalAccountFullnameAndDesc(
  125. IN LPWSTR pszAccOrgName,
  126. IN LPWSTR pszAccFullName,
  127. IN LPWSTR pszAccDesc
  128. );
  129. //
  130. // Enable/disable a user account
  131. //
  132. DWORD
  133. EnableLocalAccount(
  134. IN LPWSTR pszUserName,
  135. IN BOOL bEnable
  136. );
  137. //
  138. // Change local account password
  139. //
  140. DWORD
  141. ChangeLocalAccountPassword(
  142. IN LPWSTR pszUserName,
  143. IN LPWSTR pszOldPwd,
  144. IN LPWSTR pszNewPwd
  145. );
  146. //
  147. // Check if a specific group exist
  148. // on local machine.
  149. //
  150. BOOL
  151. IsLocalGroupExists(
  152. IN LPWSTR pszGroupName
  153. );
  154. //
  155. // Create a local group
  156. //
  157. DWORD
  158. CreateLocalGroup(
  159. IN LPWSTR pszGroupName,
  160. IN LPWSTR pszGroupDesc,
  161. IN BOOL bAddEveryone
  162. );
  163. //
  164. // Validate a user password
  165. //
  166. BOOL
  167. ValidatePassword(
  168. IN LPWSTR UserName,
  169. IN LPWSTR Domain,
  170. IN LPWSTR Password
  171. );
  172. //
  173. // Retrieve private data saved to LSA
  174. //
  175. DWORD
  176. RetrieveKeyFromLSA(
  177. PWCHAR pwszKeyName,
  178. PBYTE * ppbKey,
  179. DWORD * pcbKey
  180. );
  181. //
  182. // Save private data to LSA
  183. //
  184. DWORD
  185. StoreKeyWithLSA(
  186. PWCHAR pwszKeyName,
  187. BYTE * pbKey,
  188. DWORD cbKey
  189. );
  190. //
  191. // Open LSA policy
  192. //
  193. DWORD
  194. OpenPolicy(
  195. LPWSTR ServerName,
  196. DWORD DesiredAccess,
  197. PLSA_HANDLE PolicyHandle
  198. );
  199. //
  200. // Initialize LSA string
  201. //
  202. void
  203. InitLsaString(
  204. PLSA_UNICODE_STRING LsaString,
  205. LPWSTR String
  206. );
  207. #ifdef DBG
  208. void
  209. DebugPrintf(
  210. IN LPCTSTR format, ...
  211. );
  212. #else
  213. #define DebugPrintf
  214. #endif //PRIVATE_DEBUG
  215. //
  216. // Convert a user SID to string form
  217. //
  218. BOOL
  219. GetTextualSid(
  220. IN PSID pSid,
  221. IN OUT LPTSTR TextualSid,
  222. IN OUT LPDWORD lpdwBufferLen
  223. );
  224. DWORD
  225. IsUserAdmin(
  226. BOOL* bMember
  227. );
  228. BOOL
  229. LookupAliasFromRid(
  230. LPWSTR pTargetComputer,
  231. DWORD Rid,
  232. LPWSTR pName,
  233. PDWORD cchName
  234. );
  235. #else
  236. #define DebugPrintf
  237. #endif
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241. #endif