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.

413 lines
15 KiB

  1. //============================================================
  2. //
  3. // WBEMNetAPI32.h - NetAPI32.DLL access class definition
  4. //
  5. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. // 01/21/97 a-jmoon created
  8. //
  9. //============================================================
  10. #ifndef __WBEMNETAPI32__
  11. #define __WBEMNETAPI32__
  12. #include <lmaccess.h>
  13. #include <lmapibuf.h>
  14. #include <lmserver.h>
  15. #include <lmerr.h>
  16. #include <ntsecapi.h>
  17. #include <stack>
  18. #include <comdef.h>
  19. #include <dsrole.h> // KMH 32414
  20. #include <dsgetdc.h>
  21. #include "netapi32api.h"
  22. #include "svrapiapi.h"
  23. #include "AdvApi32Api.h"
  24. class CNetAPI32
  25. {
  26. public :
  27. CNetAPI32() ;
  28. ~CNetAPI32() ;
  29. LONG Init() ;
  30. #ifdef NTONLY
  31. // Use this version for all NT platforms. It properly gets a DC rather than
  32. // requiring that the PDC be obtained.
  33. DWORD GetDCName(
  34. LPCWSTR wstrDomain,
  35. CHString& chstrDCName);
  36. // Determines if the specified server is a DC. NULL means current machine
  37. BOOL IsDomainController(LPTSTR Server);
  38. // Returns an array of Trusted domains. Includes the current domain.
  39. BOOL GetTrustedDomainsNT(CHStringArray& achsTrustList);
  40. // Overload, returns same, but as a stack of _bstr_t's
  41. BOOL GetTrustedDomainsNT(std::vector<_bstr_t>& vectorTrustList);
  42. NET_API_STATUS NET_API_FUNCTION NetGroupEnum(LPCWSTR servername,
  43. DWORD level,
  44. LPBYTE *bufptr,
  45. DWORD prefmaxlen,
  46. LPDWORD entriesread,
  47. LPDWORD totalentries,
  48. PDWORD_PTR resume_handle) ;
  49. NET_API_STATUS NET_API_FUNCTION NetLocalGroupEnum(LPCWSTR servername,
  50. DWORD level,
  51. LPBYTE *bufptr,
  52. DWORD prefmaxlen,
  53. LPDWORD entriesread,
  54. LPDWORD totalentries,
  55. PDWORD_PTR resumehandle) ;
  56. NET_API_STATUS NET_API_FUNCTION NetGroupGetInfo(LPCWSTR servername,
  57. LPCWSTR groupname,
  58. DWORD level,
  59. LPBYTE *bufptr) ;
  60. NET_API_STATUS NET_API_FUNCTION NetGroupSetInfo(LPCWSTR servername,
  61. LPCWSTR groupname,
  62. DWORD level,
  63. LPBYTE buf,
  64. LPDWORD parm_err) ;
  65. NET_API_STATUS NET_API_FUNCTION NetLocalGroupGetInfo(LPCWSTR servername,
  66. LPCWSTR groupname,
  67. DWORD level,
  68. LPBYTE *bufptr) ;
  69. NET_API_STATUS NET_API_FUNCTION NetLocalGroupSetInfo(LPCWSTR servername,
  70. LPCWSTR groupname,
  71. DWORD level,
  72. LPBYTE buf,
  73. LPDWORD a_parm_err ) ;
  74. NET_API_STATUS NET_API_FUNCTION NetGroupGetUsers(LPCWSTR servername,
  75. LPCWSTR groupname,
  76. DWORD level,
  77. LPBYTE *bufptr,
  78. DWORD prefmaxlen,
  79. LPDWORD entriesread,
  80. LPDWORD totalentries,
  81. PDWORD_PTR ResumeHandle) ;
  82. NET_API_STATUS NET_API_FUNCTION NetLocalGroupGetMembers(LPCWSTR servername,
  83. LPCWSTR groupname,
  84. DWORD level,
  85. LPBYTE *bufptr,
  86. DWORD prefmaxlen,
  87. LPDWORD entriesread,
  88. LPDWORD totalentries,
  89. PDWORD_PTR ResumeHandle) ;
  90. NET_API_STATUS NET_API_FUNCTION NetShareEnum(LPTSTR servername,
  91. DWORD level,
  92. LPBYTE *bufptr,
  93. DWORD prefmaxlen,
  94. LPDWORD entriesread,
  95. LPDWORD totalentries,
  96. LPDWORD resume_handle) ;
  97. NET_API_STATUS NET_API_FUNCTION NetShareGetInfo(LPTSTR servername,
  98. LPTSTR netname,
  99. DWORD level,
  100. LPBYTE *bufptr) ;
  101. NET_API_STATUS NET_API_FUNCTION NetShareAdd (
  102. IN LPTSTR servername,
  103. IN DWORD level,
  104. IN LPBYTE buf,
  105. OUT LPDWORD parm_err
  106. );
  107. NET_API_STATUS NET_API_FUNCTION NetShareEnumSticky (
  108. IN LPTSTR servername,
  109. IN DWORD level,
  110. OUT LPBYTE *bufptr,
  111. IN DWORD prefmaxlen,
  112. OUT LPDWORD entriesread,
  113. OUT LPDWORD totalentries,
  114. IN OUT LPDWORD resume_handle
  115. );
  116. NET_API_STATUS NET_API_FUNCTION NetShareSetInfo (
  117. IN LPTSTR servername,
  118. IN LPTSTR netname,
  119. IN DWORD level,
  120. IN LPBYTE buf,
  121. OUT LPDWORD parm_err
  122. );
  123. NET_API_STATUS NET_API_FUNCTION NetShareDel (
  124. IN LPTSTR servername,
  125. IN LPTSTR netname,
  126. IN DWORD reserved
  127. );
  128. NET_API_STATUS NET_API_FUNCTION NetShareDelSticky (
  129. IN LPTSTR servername,
  130. IN LPTSTR netname,
  131. IN DWORD reserved
  132. );
  133. NET_API_STATUS NET_API_FUNCTION NetShareCheck (
  134. IN LPTSTR servername,
  135. IN LPTSTR device,
  136. OUT LPDWORD type
  137. );
  138. BOOL DsRolepGetPrimaryDomainInformationDownlevel (
  139. DSROLE_MACHINE_ROLE &a_rMachineRole,
  140. DWORD &a_rdwWin32Err
  141. ) ;
  142. #endif
  143. #ifdef WIN9XONLY
  144. NET_API_STATUS NET_API_FUNCTION NetShareEnum95(char FAR *servername,
  145. short level,
  146. char FAR *bufptr,
  147. unsigned short prefmaxlen,
  148. unsigned short FAR *entriesread,
  149. unsigned short FAR *totalentries);
  150. NET_API_STATUS NET_API_FUNCTION NetShareGetInfo95(char FAR *servername,
  151. char FAR *netname,
  152. short level,
  153. char FAR *bufptr,
  154. unsigned short buflen,
  155. unsigned short FAR *totalavail) ;
  156. //svrapi.h
  157. NET_API_STATUS NET_API_FUNCTION CNetAPI32::NetShareAdd95 (
  158. IN const char FAR * servername,
  159. IN short level,
  160. IN const char FAR * buf,
  161. unsigned short cbBuffer
  162. );
  163. NET_API_STATUS NET_API_FUNCTION CNetAPI32::NetShareSetInfo95 (
  164. IN const char FAR * servername,
  165. IN const char FAR * netname,
  166. IN short level,
  167. IN const char FAR* buf,
  168. IN unsigned short cbBuffer,
  169. IN short sParmNum
  170. ) ;
  171. NET_API_STATUS NET_API_FUNCTION NetShareDel95 (
  172. IN LPTSTR servername,
  173. IN LPTSTR netname,
  174. IN DWORD reserved
  175. );
  176. NET_API_STATUS NET_API_FUNCTION NetServerGetInfo95(
  177. char FAR *servername,
  178. short level,
  179. char FAR *bufptr,
  180. unsigned short buflen,
  181. unsigned short FAR *totalavail);
  182. #endif
  183. #ifdef NTONLY
  184. NET_API_STATUS NET_API_FUNCTION NetUserEnum(LPCWSTR servername,
  185. DWORD level,
  186. DWORD filter,
  187. LPBYTE *bufptr,
  188. DWORD prefmaxlen,
  189. LPDWORD entriesread,
  190. LPDWORD totalentries,
  191. LPDWORD resume_handle) ;
  192. NET_API_STATUS NET_API_FUNCTION NetUserGetInfo(LPCWSTR servername,
  193. LPCWSTR username,
  194. DWORD level,
  195. LPBYTE *bufptr) ;
  196. NET_API_STATUS NET_API_FUNCTION NetUserSetInfo(
  197. LPCWSTR a_servername,
  198. LPCWSTR a_username,
  199. DWORD a_level,
  200. LPBYTE a_buf,
  201. LPDWORD a_parm_err
  202. ) ;
  203. NET_API_STATUS NET_API_FUNCTION NetApiBufferFree(void *bufptr) ;
  204. NET_API_STATUS NET_API_FUNCTION NetQueryDisplayInformation( LPWSTR ServerName,
  205. DWORD Level,
  206. DWORD Index,
  207. DWORD EntriesRequested,
  208. DWORD PreferredMaximumLength,
  209. LPDWORD ReturnedEntryCount,
  210. PVOID *SortedBuffer);
  211. NET_API_STATUS NET_API_FUNCTION NetServerSetInfo(LPTSTR servername,
  212. DWORD level,
  213. LPBYTE bufptr,
  214. LPDWORD ParmError);
  215. NET_API_STATUS NET_API_FUNCTION NetServerGetInfo(LPTSTR servername,
  216. DWORD level,
  217. LPBYTE *bufptr);
  218. //KMH 32414
  219. NET_API_STATUS NET_API_FUNCTION DSRoleGetPrimaryDomainInfo(LPCWSTR servername,
  220. DSROLE_PRIMARY_DOMAIN_INFO_LEVEL level,
  221. LPBYTE *bufptr);
  222. NET_API_STATUS NET_API_FUNCTION DSRoleFreeMemory(LPBYTE bufptr);
  223. NET_API_STATUS NET_API_FUNCTION NetGetDCName( LPCWSTR ServerName,
  224. LPCWSTR DomainName,
  225. LPBYTE* bufptr );
  226. // NT5 entry
  227. NET_API_STATUS NET_API_FUNCTION DsGetDcName( LPCTSTR ComputerName,
  228. LPCTSTR DomainName,
  229. GUID *DomainGuid,
  230. LPCTSTR SiteName,
  231. ULONG Flags,
  232. PDOMAIN_CONTROLLER_INFO *DomainControllerInfo );
  233. NET_API_STATUS NET_API_FUNCTION NetRenameMachineInDomain( LPCWSTR a_lpServer,
  234. LPCWSTR a_lpNewMachineName,
  235. LPCWSTR a_lpAccount,
  236. LPCWSTR a_lpPassword,
  237. DWORD a_fRenameOptions);
  238. NET_API_STATUS NET_API_FUNCTION NetUnjoinDomain( LPCWSTR lpServer,
  239. LPCWSTR lpAccount,
  240. LPCWSTR lpPassword,
  241. DWORD fUnjoinOptions);
  242. NET_API_STATUS NET_API_FUNCTION NetJoinDomain( LPCWSTR lpServer,
  243. LPCWSTR lpDomain,
  244. LPCWSTR lpAccountOU,
  245. LPCWSTR lpAccount,
  246. LPCWSTR lpPassword,
  247. DWORD fJoinOptions);
  248. NET_API_STATUS NET_API_FUNCTION NetWkstaGetInfo( LPWSTR ServerName,
  249. DWORD level,
  250. LPBYTE *bufptr );
  251. NET_API_STATUS NET_API_FUNCTION NetGetAnyDCName(LPWSTR ServerName,
  252. LPWSTR DomainName,
  253. LPBYTE* bufptr );
  254. NET_API_STATUS NET_API_FUNCTION NetServerEnum( LPTSTR servername,
  255. DWORD level,
  256. LPBYTE *bufptr,
  257. DWORD prefmaxlen,
  258. LPDWORD entriesread,
  259. LPDWORD totalentries,
  260. DWORD servertype,
  261. LPTSTR domain,
  262. LPDWORD resume_handle );
  263. NET_API_STATUS NET_API_FUNCTION NetEnumerateTrustedDomains( LPWSTR servername,
  264. LPWSTR* domainNames ) ;
  265. NET_API_STATUS NET_API_FUNCTION NetUserModalsGet( LPWSTR servername,
  266. DWORD level,
  267. LPBYTE *bufptr );
  268. NET_API_STATUS NET_API_FUNCTION NetScheduleJobAdd (
  269. IN LPCWSTR Servername OPTIONAL,
  270. IN LPBYTE Buffer,
  271. OUT LPDWORD JobId
  272. );
  273. NET_API_STATUS NET_API_FUNCTION NetScheduleJobDel (
  274. IN LPCWSTR Servername OPTIONAL,
  275. IN DWORD MinJobId,
  276. IN DWORD MaxJobId
  277. );
  278. NET_API_STATUS NET_API_FUNCTION NetScheduleJobEnum (
  279. IN LPCWSTR Servername OPTIONAL,
  280. OUT LPBYTE * PointerToBuffer,
  281. IN DWORD PrefferedMaximumLength,
  282. OUT LPDWORD EntriesRead,
  283. OUT LPDWORD TotalEntries,
  284. IN OUT LPDWORD ResumeHandle
  285. );
  286. NET_API_STATUS NET_API_FUNCTION NetScheduleJobGetInfo (
  287. IN LPCWSTR Servername OPTIONAL,
  288. IN DWORD JobId,
  289. OUT LPBYTE * PointerToBuffer
  290. );
  291. NET_API_STATUS NET_API_FUNCTION NetUseGetInfo (
  292. IN LPCWSTR UncServerName OPTIONAL,
  293. IN LPCWSTR UseName,
  294. IN DWORD Level,
  295. OUT LPBYTE *BufPtr
  296. );
  297. #endif
  298. private :
  299. #ifdef NTONLY
  300. CNetApi32Api *m_pnetapi;
  301. #endif
  302. #ifdef WIN9XONLY
  303. CSvrApiApi *m_psvrapi;
  304. #endif
  305. NTSTATUS OpenPolicy( CAdvApi32Api * a_padvapi , LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle);
  306. void InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String );
  307. BOOL EnumTrustedDomains(LSA_HANDLE PolicyHandle, CHStringArray &achsTrustList);
  308. // Overload of above to accept stl stack instead of a CHStringArray.
  309. BOOL EnumTrustedDomains(LSA_HANDLE PolicyHandle, std::vector<_bstr_t>& vectorTrustList);
  310. bool AlreadyAddedToList(std::vector<_bstr_t> &vecchsList, _bstr_t &bstrtItem);
  311. #ifdef NTONLY
  312. /*
  313. * This enumerated type taken from ntdef.h
  314. */
  315. typedef enum _NT_PRODUCT_TYPE {
  316. NtProductWinNt = 1,
  317. NtProductLanManNt,
  318. NtProductServer
  319. } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
  320. BOOL DsRolepGetProductTypeForServer (
  321. NT_PRODUCT_TYPE &a_rProductType ,
  322. DWORD &a_rdwWin32Err
  323. ) ;
  324. #endif
  325. } ;
  326. #endif // File inclusion