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.

397 lines
8.6 KiB

  1. /*++
  2. Copyright (c) 1997 - 1997 Microsoft Corporation
  3. Module Name:
  4. netsetp.h
  5. Abstract:
  6. Private definitions and prototypes for the Net setup apis
  7. Author:
  8. Mac McLain (MacM) 19-Feb-1997
  9. Environment:
  10. User mode only.
  11. Revision History:
  12. --*/
  13. #ifndef __NETSETP_H__
  14. #define __NETSETP_H__
  15. #include <nt.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #include <ntlsa.h>
  19. #include <windows.h>
  20. #if(_WIN32_WINNT >= 0x0500)
  21. #include <dsgetdc.h>
  22. #endif
  23. #include <lmcons.h>
  24. #include <lmapibuf.h>
  25. #include <lmerr.h>
  26. #include <lmjoin.h>
  27. #include <netsetup.h>
  28. #include <stdio.h>
  29. #include <netdebug.h>
  30. #define NETSETUPP_CONNECT_IPC 0x00000001
  31. #define NETSETUPP_DISCONNECT_IPC 0x00000002
  32. #define NETSETUPP_NULL_SESSION_IPC 0x00000010
  33. #define NETSETUPP_USE_LOTS_FORCE 0x00000020
  34. #define NETSETUPP_CREATE 0
  35. #define NETSETUPP_DELETE 1
  36. #define NETSETUPP_RENAME 2
  37. #define NETSETUPP_SET_PASSWORD 3
  38. #define NETSETUP_SVC_STOPPED 0x00000001
  39. #define NETSETUP_SVC_STARTED 0x00000002
  40. #define NETSETUP_SVC_ENABLED 0x00000004
  41. #define NETSETUP_SVC_DISABLED 0x00000008
  42. #define NETSETUP_SVC_MANUAL 0x00000010
  43. #define NETSETUPP_SVC_NETLOGON 0x00000001
  44. #define NETSETUPP_SVC_TIMESVC 0x00000002
  45. #define NETSETUP_IGNORE_JOIN 0x80000000
  46. #define NETSETUP_VERBOSE_LOGGING
  47. extern HANDLE DebugLog;
  48. //
  49. // For debug output
  50. //
  51. #define PREFIX_NETJOIN "[WKSSVC]NetJoin: "
  52. //
  53. // Flags passed to DsGetDcName
  54. //
  55. #if(_WIN32_WINNT >= 0x0500)
  56. #define NETSETUPP_DSGETDC_FLAGS \
  57. (DS_DIRECTORY_SERVICE_PREFERRED | DS_WRITABLE_REQUIRED )
  58. #define NETSETUP_DSGETDC_FLAGS_ACCOUNT_EXISTS \
  59. ( DS_DIRECTORY_SERVICE_PREFERRED | DS_WRITABLE_REQUIRED )
  60. #else
  61. #define NETSETUPP_DSGETDC_FLAGS 0
  62. #define NETSETUP_DSGETDC_FLAGS_ACCOUNT_EXISTS 0
  63. #define DS_DS_FLAG 0x00000001
  64. #endif
  65. //
  66. // Helpful macros
  67. //
  68. //
  69. // Determines whether a bit flag is turned on or not
  70. //
  71. #define FLAG_ON(flag,bits) ((flag) & (bits))
  72. //
  73. // Determine whether the client is joined to a domain or not given the LSAs
  74. // primary domain information
  75. //
  76. #define IS_CLIENT_JOINED(plsapdinfo) \
  77. ((plsapdinfo)->Sid != NULL && (plsapdinfo)->Name.Length != 0 ? TRUE : FALSE)
  78. #ifdef NETSETUP_VERBOSE_LOGGING
  79. //#define NetpLog(x) NetpLogPrintHelper x
  80. #else
  81. #define NetSetuppLogPrint(x)
  82. #define NetSetuppOpenLog()
  83. #define NetSetuppCloseLog()
  84. #endif
  85. typedef struct _NETSETUP_SAVED_JOIN_STATE {
  86. BOOLEAN MachineSecret;
  87. PUNICODE_STRING CurrentValue;
  88. PUNICODE_STRING PreviousValue;
  89. PPOLICY_PRIMARY_DOMAIN_INFO PrimaryDomainInfo;
  90. #if(_WIN32_WINNT >= 0x0500)
  91. PPOLICY_DNS_DOMAIN_INFO DnsDomainInfo;
  92. #endif
  93. } NETSETUP_SAVED_JOIN_STATE, *PNETSETUP_SAVED_JOIN_STATE;
  94. //
  95. // netjoin.c functions
  96. //
  97. NET_API_STATUS
  98. NET_API_FUNCTION
  99. NetpManageMachineAccount(
  100. IN LPWSTR lpMachine,
  101. IN LPWSTR lpOldMachine,
  102. IN LPWSTR lpDcName,
  103. IN LPWSTR lpPassword,
  104. IN ULONG fControl,
  105. IN ULONG AccountOptions,
  106. IN BOOL fIsNt4Dc
  107. );
  108. NET_API_STATUS
  109. NET_API_FUNCTION
  110. NetpManageMachineAccountWithSid(
  111. IN LPWSTR lpMachine,
  112. IN LPWSTR lpOldMachine,
  113. IN LPWSTR lpDcName,
  114. IN LPWSTR lpPassword,
  115. IN PSID DomainSid,
  116. IN ULONG fControl,
  117. IN ULONG AccountOptions,
  118. IN BOOL fIsNt4Dc
  119. );
  120. //
  121. // netplsa.c functions
  122. //
  123. NET_API_STATUS
  124. NET_API_FUNCTION
  125. NetpHandleJoinedStateInfo(
  126. IN PNETSETUP_SAVED_JOIN_STATE SavedState,
  127. IN BOOLEAN Save,
  128. OUT PLSA_HANDLE ReturnedPolicyHandle OPTIONAL
  129. );
  130. NET_API_STATUS
  131. NET_API_FUNCTION
  132. NetpSetLsaPrimaryDomain(
  133. IN LPWSTR lpDomain,
  134. IN PSID pDomainSid, OPTIONAL
  135. #if(_WIN32_WINNT >= 0x0500)
  136. IN PPOLICY_DNS_DOMAIN_INFO pPolicyDns, OPTIONAL
  137. #endif
  138. OUT PLSA_HANDLE pPolicyHandle OPTIONAL
  139. );
  140. NET_API_STATUS
  141. NET_API_FUNCTION
  142. NetpGetLsaPrimaryDomain(
  143. IN LPWSTR lpServer, OPTIONAL
  144. OUT PPOLICY_PRIMARY_DOMAIN_INFO *ppPolicyPDI,
  145. #if(_WIN32_WINNT >= 0x0500)
  146. OUT PPOLICY_DNS_DOMAIN_INFO *ppPolicyDns,
  147. #endif
  148. OUT PLSA_HANDLE pPolicyHandle OPTIONAL
  149. );
  150. NET_API_STATUS
  151. NET_API_FUNCTION
  152. NetpGetLsaDcRole(
  153. IN LPWSTR lpMachine,
  154. OUT BOOL *pfIsDC
  155. );
  156. NET_API_STATUS
  157. NET_API_FUNCTION
  158. NetpManageMachineSecret(
  159. IN LPWSTR lpMachine,
  160. IN LPWSTR lpPassword,
  161. IN DWORD Action,
  162. IN BOOL UseDefaultForOldPwd,
  163. OUT PLSA_HANDLE pPolicyHandle OPTIONAL
  164. );
  165. NET_API_STATUS
  166. NET_API_FUNCTION
  167. NetpReadCurrentSecret(
  168. OUT LPWSTR *lpCurrentSecret,
  169. OUT PLSA_HANDLE pPolicyHandle OPTIONAL
  170. );
  171. NET_API_STATUS
  172. NET_API_FUNCTION
  173. NetpSetNetlogonDomainCache(
  174. IN LPWSTR lpDc
  175. );
  176. NET_API_STATUS
  177. NET_API_FUNCTION
  178. NetpManageLocalGroups(
  179. IN PSID pDomainSid,
  180. IN BOOL fDelete
  181. );
  182. NET_API_STATUS
  183. NET_API_FUNCTION
  184. NetpValidateMachineAccount(
  185. IN LPWSTR lpDc,
  186. IN LPWSTR lpDomain,
  187. IN LPWSTR lpMachine,
  188. IN LPWSTR lpPassword
  189. );
  190. NET_API_STATUS
  191. NET_API_FUNCTION
  192. NetpSetMachineAccountPassword(
  193. IN LPWSTR lpDc,
  194. IN LPWSTR lpMachine,
  195. IN LPWSTR lpPassword
  196. );
  197. NET_API_STATUS
  198. NET_API_FUNCTION
  199. NetpStopService(
  200. IN LPWSTR Service,
  201. IN SC_HANDLE SCManager
  202. );
  203. NET_API_STATUS
  204. NET_API_FUNCTION
  205. NetpSetTimeServiceParameters(
  206. VOID
  207. );
  208. NET_API_STATUS
  209. NET_API_FUNCTION
  210. NetpDsGetDcName(
  211. IN LPWSTR ComputerName, OPTIONAL
  212. IN LPWSTR DomainName,
  213. IN LPWSTR AccountName, OPTIONAL
  214. IN ULONG Flags,
  215. IN OUT PULONG DcFlags,
  216. OUT PWSTR *DomainControllerName
  217. #if(_WIN32_WINNT >= 0x0500)
  218. ,
  219. OUT PDOMAIN_CONTROLLER_INFO *DcInfo
  220. #endif
  221. );
  222. NET_API_STATUS
  223. NET_API_FUNCTION
  224. NetpCrackDomainSpecifier(
  225. IN LPWSTR DomainSpecifier,
  226. OUT LPWSTR* DomainName,
  227. OUT LPWSTR* DomainControllerName
  228. );
  229. //
  230. // joinutl.c
  231. //
  232. NET_API_STATUS
  233. NET_API_FUNCTION
  234. NetpCreateComputerObjectInOU(
  235. IN LPWSTR DC,
  236. IN LPWSTR OU,
  237. IN LPWSTR ComputerName,
  238. IN LPWSTR Account,
  239. IN LPWSTR Password,
  240. IN LPWSTR MachinePassword
  241. );
  242. NET_API_STATUS
  243. NetpGetDnsHostName(
  244. IN LPWSTR PassedHostName OPTIONAL,
  245. IN PUNICODE_STRING DnsDomainName,
  246. IN BOOL UseGpSuffix,
  247. OUT LPWSTR *DnsHostName
  248. );
  249. NET_API_STATUS
  250. NET_API_FUNCTION
  251. NetpCreateComputerObjectInDs(
  252. IN PDOMAIN_CONTROLLER_INFO DcInfo,
  253. IN LPWSTR Account,
  254. IN LPWSTR Password,
  255. IN LPWSTR ComputerName,
  256. IN LPWSTR MachinePassword,
  257. IN LPWSTR DnsHostName OPTIONAL,
  258. IN LPWSTR OU OPTIONAL
  259. );
  260. NET_API_STATUS
  261. NET_API_FUNCTION
  262. NetpSetDnsHostNameAndSpn(
  263. IN PDOMAIN_CONTROLLER_INFO DcInfo,
  264. IN LPWSTR Account,
  265. IN LPWSTR Password,
  266. IN LPWSTR ComputerName,
  267. IN LPWSTR DnsHostName
  268. );
  269. NET_API_STATUS
  270. NET_API_FUNCTION
  271. NetpDeleteComputerObjectInOU(
  272. IN LPWSTR DC,
  273. IN LPWSTR OU,
  274. IN LPWSTR ComputerName,
  275. IN LPWSTR Account,
  276. IN LPWSTR Password
  277. );
  278. NET_API_STATUS
  279. NET_API_FUNCTION
  280. NetpSetMachineAccountPasswordAndType(
  281. IN LPWSTR lpDcName,
  282. IN PSID DomainSid,
  283. IN LPWSTR lpAccountName,
  284. IN LPWSTR lpPassword
  285. );
  286. #define ACCOUNT_STATE_IGNORE 0
  287. #define ACCOUNT_STATE_ENABLED 1
  288. #define ACCOUNT_STATE_DISABLED 2
  289. NET_API_STATUS
  290. NET_API_FUNCTION
  291. NetpSetMachineAccountPasswordAndTypeEx(
  292. IN LPWSTR lpDcName,
  293. IN PSID DomainSid,
  294. IN LPWSTR lpAccountName,
  295. IN OPTIONAL LPWSTR lpPassword,
  296. IN OPTIONAL UCHAR AccountState,
  297. IN BOOL fIsNt4Dc
  298. );
  299. #if defined(REMOTE_BOOT) && (_WIN32_WINNT >= 0x0500)
  300. NET_API_STATUS
  301. NET_API_FUNCTION
  302. NetpGetRemoteBootMachinePassword(
  303. OUT LPWSTR Password
  304. );
  305. #endif
  306. NET_API_STATUS
  307. NET_API_FUNCTION
  308. NetpUpdateDnsRegistrations (
  309. IN BOOL AddRegistrations
  310. );
  311. #if(_WIN32_WINNT >= 0x0500)
  312. NET_API_STATUS
  313. NET_API_FUNCTION
  314. NetpStoreIntialDcRecord(
  315. IN PDOMAIN_CONTROLLER_INFO DcInfo
  316. );
  317. #endif
  318. NET_API_STATUS
  319. NET_API_FUNCTION
  320. NetpSetComputerAccountPassword(
  321. IN PWSTR szMachine,
  322. IN PWSTR szDomainController,
  323. IN PWSTR szUser,
  324. IN PWSTR szUserPassword,
  325. IN PVOID Reserved
  326. );
  327. #endif // __NETSETP_H__