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.

251 lines
4.3 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. #define MAX_HELPACCOUNT_PASSWORD LM20_PWLEN // from lmcons.h
  16. #define MIN_HELPACCOUNT_PASSWORD 4 // for special characters
  17. typedef HRESULT (WINAPI* RegEnumKeyCallback)(
  18. IN HKEY hKey,
  19. IN LPTSTR pszKeyName,
  20. IN HANDLE userData
  21. );
  22. #include <ntsecapi.h>
  23. #ifdef __cplusplus
  24. extern "C"{
  25. #endif
  26. DWORD
  27. GenerateRandomString(
  28. IN DWORD dwSizeRandomSeed,
  29. IN OUT LPTSTR* pszRandomString
  30. );
  31. DWORD
  32. GenerateRandomBytes(
  33. IN DWORD dwSize,
  34. IN OUT LPBYTE pbBuffer
  35. );
  36. void
  37. UnixTimeToFileTime(
  38. time_t t,
  39. LPFILETIME pft
  40. );
  41. long
  42. GetUserTSLogonId();
  43. //
  44. // create a random password, buffer must
  45. // be at least MIN_HELPACCOUNT_PASSWORD characters
  46. DWORD
  47. CreatePassword(
  48. TCHAR *pszPassword,
  49. DWORD length
  50. );
  51. DWORD
  52. RegEnumSubKeys(
  53. IN HKEY hKey,
  54. IN LPCTSTR pszSubKey,
  55. IN RegEnumKeyCallback pFunc,
  56. IN HANDLE userData
  57. );
  58. DWORD
  59. RegDelKey(
  60. IN HKEY hRegKey,
  61. IN LPCTSTR pszSubKey
  62. );
  63. DWORD
  64. GetUserSid(
  65. PBYTE* ppbSid,
  66. DWORD* pcbSid
  67. );
  68. HRESULT
  69. GetUserSidString(
  70. OUT CComBSTR& bstrSid
  71. );
  72. BOOL
  73. IsPersonalOrProMachine();
  74. //
  75. // Create a local account
  76. //
  77. DWORD
  78. CreateLocalAccount(
  79. IN LPWSTR pszUserName,
  80. IN LPWSTR pszUserPwd,
  81. IN LPWSTR pszUserFullName,
  82. IN LPWSTR pszUserDesc,
  83. IN LPWSTR pszGroupName,
  84. IN LPWSTR pszScript,
  85. OUT BOOL* pbAccountExists
  86. );
  87. //
  88. // Check if a user account is enabled.
  89. //
  90. DWORD
  91. IsLocalAccountEnabled(
  92. IN LPWSTR pszUserName,
  93. IN BOOL* pEnabled
  94. );
  95. //
  96. // Rename local account
  97. //
  98. DWORD
  99. RenameLocalAccount(
  100. IN LPWSTR pszOrgName,
  101. IN LPWSTR pszNewName
  102. );
  103. DWORD
  104. UpdateLocalAccountFullnameAndDesc(
  105. IN LPWSTR pszAccOrgName,
  106. IN LPWSTR pszAccFullName,
  107. IN LPWSTR pszAccDesc
  108. );
  109. //
  110. // Enable/disable a user account
  111. //
  112. DWORD
  113. EnableLocalAccount(
  114. IN LPWSTR pszUserName,
  115. IN BOOL bEnable
  116. );
  117. //
  118. // Change local account password
  119. //
  120. DWORD
  121. ChangeLocalAccountPassword(
  122. IN LPWSTR pszUserName,
  123. IN LPWSTR pszOldPwd,
  124. IN LPWSTR pszNewPwd
  125. );
  126. //
  127. // Validate a user password
  128. //
  129. BOOL
  130. ValidatePassword(
  131. IN LPWSTR UserName,
  132. IN LPWSTR Domain,
  133. IN LPWSTR Password
  134. );
  135. //
  136. // Retrieve private data saved to LSA
  137. //
  138. DWORD
  139. RetrieveKeyFromLSA(
  140. PWCHAR pwszKeyName,
  141. PBYTE * ppbKey,
  142. DWORD * pcbKey
  143. );
  144. //
  145. // Save private data to LSA
  146. //
  147. DWORD
  148. StoreKeyWithLSA(
  149. PWCHAR pwszKeyName,
  150. BYTE * pbKey,
  151. DWORD cbKey
  152. );
  153. //
  154. // Open LSA policy
  155. //
  156. DWORD
  157. OpenPolicy(
  158. LPWSTR ServerName,
  159. DWORD DesiredAccess,
  160. PLSA_HANDLE PolicyHandle
  161. );
  162. //
  163. // Initialize LSA string
  164. //
  165. void
  166. InitLsaString(
  167. PLSA_UNICODE_STRING LsaString,
  168. LPWSTR String
  169. );
  170. #ifdef DBG
  171. void
  172. DebugPrintf(
  173. IN LPCTSTR format, ...
  174. );
  175. #else
  176. #define DebugPrintf
  177. #endif //PRIVATE_DEBUG
  178. //
  179. // Convert a user SID to string form
  180. //
  181. BOOL
  182. GetTextualSid(
  183. IN PSID pSid,
  184. IN OUT LPTSTR TextualSid,
  185. IN OUT LPDWORD lpdwBufferLen
  186. );
  187. DWORD
  188. IsUserAdmin(
  189. BOOL* bMember
  190. );
  191. HRESULT
  192. ConvertSidToAccountName(
  193. IN CComBSTR& SidString,
  194. IN BSTR* ppszDomain,
  195. IN BSTR* ppszUserAcc
  196. );
  197. #ifdef __cplusplus
  198. }
  199. #endif
  200. #endif