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.

778 lines
23 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. MSERVER.C
  5. Abstract:
  6. 32 bit version of mapping routines for NetServerGet/SetInfo API
  7. Author:
  8. Dan Hinsley (danhi) 06-Jun-1991
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. 24-Apr-1991 danhi
  13. Created
  14. 06-Jun-1991 Danhi
  15. Sweep to conform to NT coding style
  16. 08-Aug-1991 JohnRo
  17. Implement downlevel NetWksta APIs.
  18. Made some UNICODE changes.
  19. Got rid of tabs in source file.
  20. 15-Aug-1991 W-ShankN
  21. Added UNICODE mapping layer.
  22. 02-Apr-1992 beng
  23. Added xport apis
  24. 26-Aug-1992 JohnRo
  25. RAID 4463: NetServerGetInfo(level 3) to downlevel: assert in convert.c.
  26. --*/
  27. //
  28. // INCLUDES
  29. //
  30. #include <nt.h>
  31. #include <windef.h>
  32. #include <ntrtl.h>
  33. #include <winerror.h>
  34. #include <stdio.h>
  35. #include <memory.h>
  36. #include <tstring.h>
  37. #include <malloc.h>
  38. #include <stddef.h>
  39. #include <excpt.h>
  40. #include <lmcons.h>
  41. #include <lmerr.h> // NERR_ equates.
  42. #include <lmserver.h> // NetServer APIs.
  43. #include <lmapibuf.h> // NetApiBufferFree
  44. #include <mapsupp.h> // BUILD_LENGTH_ARRAY
  45. #include <xsdef16.h> // DEF16_*
  46. #include <dlserver.h> // SERVER_INFO_0
  47. #include <mserver.h>
  48. NET_API_STATUS
  49. NetpMakeServerLevelForNT(
  50. IN DWORD Level,
  51. PSERVER_INFO_102 pLevel102,
  52. PSERVER_INFO_502 pLevel402,
  53. PSERVER_INFO_2 * ppLevel2
  54. );
  55. NET_API_STATUS
  56. NetpMakeServerLevelForOS2(
  57. IN DWORD Level,
  58. PSERVER_INFO_102 pLevel102,
  59. PSERVER_INFO_402 pLevel402,
  60. PSERVER_INFO_2 * ppLevel2
  61. );
  62. NET_API_STATUS
  63. NetpSplitServerForNT(
  64. LPTSTR Server,
  65. IN DWORD Level,
  66. PSERVER_INFO_2 pLevel2,
  67. PSERVER_INFO_102 * ppLevel102,
  68. PSERVER_INFO_502 * ppLevel402
  69. );
  70. DWORD
  71. MNetServerEnum(
  72. LPTSTR pszServer,
  73. DWORD nLevel,
  74. LPBYTE * ppbBuffer,
  75. DWORD * pcEntriesRead,
  76. DWORD flServerType,
  77. LPTSTR pszDomain
  78. )
  79. {
  80. DWORD cTotalAvail;
  81. DWORD dwErr;
  82. DWORD i;
  83. LPBYTE Source;
  84. LPBYTE Dest;
  85. ASSERT(nLevel == 100 || nLevel == 101);
  86. //
  87. // In either the case of 100 or 101, all we need to do is move
  88. // the information up over the top of the platform id.
  89. //
  90. dwErr = NetServerEnum(pszServer,
  91. nLevel,
  92. ppbBuffer,
  93. MAX_PREFERRED_LENGTH,
  94. pcEntriesRead,
  95. &cTotalAvail,
  96. flServerType,
  97. pszDomain,
  98. NULL);
  99. if (dwErr == NERR_Success || dwErr == ERROR_MORE_DATA)
  100. {
  101. //
  102. // Cycle thru the returned entries, moving each one up over the
  103. // platform id. None of the strings need to be moved.
  104. //
  105. if (nLevel == 100)
  106. {
  107. for (i = 0, Source = Dest = (LPBYTE)*ppbBuffer;
  108. i < *pcEntriesRead;
  109. i++, Source += sizeof(SERVER_INFO_100), Dest += sizeof(SERVER_INFO_0))
  110. {
  111. memmove(Dest,
  112. Source + FIELD_OFFSET(SERVER_INFO_100, sv100_name),
  113. sizeof(SERVER_INFO_0));
  114. }
  115. }
  116. else
  117. {
  118. for (i = 0, Source = Dest = (LPBYTE)*ppbBuffer;
  119. i < *pcEntriesRead;
  120. i++, Source += sizeof(SERVER_INFO_101), Dest += sizeof(SERVER_INFO_1))
  121. {
  122. memmove(Dest,
  123. Source + FIELD_OFFSET(SERVER_INFO_100, sv100_name),
  124. sizeof(SERVER_INFO_1));
  125. }
  126. }
  127. }
  128. return dwErr;
  129. }
  130. DWORD
  131. MNetServerGetInfo(
  132. LPTSTR ptszServer,
  133. DWORD nLevel,
  134. LPBYTE * ppbBuffer
  135. )
  136. {
  137. DWORD ReturnCode;
  138. //
  139. // It all depends on what info level they've asked for:
  140. //
  141. switch(nLevel)
  142. {
  143. case 0:
  144. {
  145. PSERVER_INFO_100 pLevel100;
  146. //
  147. // Everything they need is in level 100. Get it.
  148. //
  149. ReturnCode = NetServerGetInfo(ptszServer, 100, (LPBYTE *) & pLevel100);
  150. if (ReturnCode)
  151. {
  152. return ReturnCode;
  153. }
  154. //
  155. // Since it's just the UNICODEZ string, just copy it up in
  156. // the RPC allocated buffer and return it.
  157. //
  158. ((PSERVER_INFO_0)(pLevel100))->sv0_name = pLevel100->sv100_name;
  159. *ppbBuffer = (LPBYTE) pLevel100;
  160. break;
  161. }
  162. case 1:
  163. {
  164. PSERVER_INFO_101 pLevel101;
  165. //
  166. // Everything they need is in level 101. Get it.
  167. //
  168. ReturnCode = NetServerGetInfo(ptszServer, 101, (LPBYTE *) & pLevel101);
  169. if (ReturnCode)
  170. {
  171. return ReturnCode;
  172. }
  173. //
  174. // Level 101 is identical to the 32 bit version of info level 1
  175. // except for the platform_id. All I have to do is move the
  176. // fields up sizeof(DWORD) and then pass the buffer on to the user.
  177. //
  178. memcpy(
  179. (LPBYTE)pLevel101,
  180. (LPBYTE)&(pLevel101->sv101_name),
  181. sizeof(SERVER_INFO_101) - sizeof(DWORD));
  182. *ppbBuffer = (LPBYTE) pLevel101;
  183. break;
  184. }
  185. case 2:
  186. case 3:
  187. {
  188. PSERVER_INFO_102 pLevel102;
  189. LPBYTE pLevel2;
  190. LPBYTE pLevelx02 = NULL;
  191. //
  192. // Level 2/3 requires information from both platform dependant and
  193. // platform independent levels. Get level 102 first, which will
  194. // tell us what platform we're running on (as well as supply some
  195. // of the other information we'll need.
  196. //
  197. ReturnCode = NetServerGetInfo(ptszServer, 102, (LPBYTE *) &pLevel102);
  198. if (ReturnCode)
  199. {
  200. return ReturnCode;
  201. }
  202. //
  203. // Get the platform dependant information and then call the
  204. // platform dependant worker function that will create the
  205. // level 2/3 structure.
  206. //
  207. if (pLevel102->sv102_platform_id == SV_PLATFORM_ID_NT) {
  208. ReturnCode = NetServerGetInfo(ptszServer, 502, & pLevelx02);
  209. if (ReturnCode)
  210. {
  211. NetApiBufferFree(pLevel102);
  212. return ReturnCode;
  213. }
  214. ReturnCode = NetpMakeServerLevelForNT(nLevel, pLevel102,
  215. (PSERVER_INFO_502) pLevelx02, (PSERVER_INFO_2 *) & pLevel2);
  216. if (ReturnCode)
  217. {
  218. NetApiBufferFree(pLevel102);
  219. NetApiBufferFree(pLevelx02);
  220. return ReturnCode;
  221. }
  222. }
  223. else if (pLevel102->sv102_platform_id == SV_PLATFORM_ID_OS2) {
  224. ReturnCode = NetServerGetInfo(ptszServer, 402, & pLevelx02);
  225. if (ReturnCode)
  226. {
  227. NetApiBufferFree(pLevel102);
  228. return ReturnCode;
  229. }
  230. ReturnCode = NetpMakeServerLevelForOS2(nLevel, pLevel102,
  231. (PSERVER_INFO_402) pLevelx02,
  232. (PSERVER_INFO_2 *) & pLevel2);
  233. if (ReturnCode)
  234. {
  235. NetApiBufferFree(pLevel102);
  236. NetApiBufferFree(pLevelx02);
  237. return ReturnCode;
  238. }
  239. }
  240. //
  241. // I got an unknown platform id back, this should never happen!
  242. //
  243. else
  244. {
  245. NetApiBufferFree(pLevel102);
  246. return(ERROR_UNEXP_NET_ERR);
  247. }
  248. //
  249. // I've built the old style structure, stick the pointer
  250. // to the new structure in the user's pointer and return.
  251. //
  252. *ppbBuffer = (LPBYTE) pLevel2;
  253. NetApiBufferFree(pLevel102);
  254. NetApiBufferFree(pLevelx02);
  255. break;
  256. }
  257. //
  258. // Not a level I recognize
  259. //
  260. default:
  261. return ERROR_INVALID_LEVEL;
  262. }
  263. return NERR_Success;
  264. }
  265. DWORD
  266. MNetServerSetInfoLevel2(
  267. LPBYTE pbBuffer
  268. )
  269. {
  270. DWORD ReturnCode;
  271. PSERVER_INFO_102 pLevel102 = NULL;
  272. PSERVER_INFO_502 pLevel502 = NULL;
  273. //
  274. // Create the NT levels based on the structure passed in
  275. //
  276. NetpSplitServerForNT(NULL,
  277. 2,
  278. (PSERVER_INFO_2) pbBuffer,
  279. &pLevel102,
  280. &pLevel502);
  281. //
  282. // Now SetInfo for both levels (takes two to cover all the
  283. // information in the old structure
  284. //
  285. ReturnCode = NetServerSetInfo(NULL, 102, (LPBYTE) pLevel102, NULL);
  286. /*
  287. // We no longer want to disable autotuning of all these parameters, so we don't set this info.
  288. // The only things settable are AutoDisc, Comment, and Hidden, which are all in the 102 structure.
  289. if (ReturnCode == NERR_Success)
  290. {
  291. ReturnCode = NetServerSetInfo(NULL, 502, (LPBYTE) pLevel502, NULL);
  292. }
  293. */
  294. NetApiBufferFree(pLevel102);
  295. NetApiBufferFree(pLevel502);
  296. return ReturnCode;
  297. }
  298. NET_API_STATUS
  299. NetpMakeServerLevelForOS2(
  300. IN DWORD Level,
  301. PSERVER_INFO_102 pLevel102,
  302. PSERVER_INFO_402 pLevel402,
  303. PSERVER_INFO_2 * ppLevel2
  304. )
  305. {
  306. DWORD BytesRequired = 0;
  307. NET_API_STATUS ReturnCode;
  308. DWORD Level2_102_Length[3];
  309. DWORD Level2_402_Length[3];
  310. DWORD Level3_403_Length[1];
  311. DWORD i;
  312. LPTSTR pFloor;
  313. //
  314. // Initialize the Level2_102_Length array with the length of each string
  315. // in the 102 and 402 buffers, and allocate the new buffer for
  316. // SERVER_INFO_2
  317. //
  318. BUILD_LENGTH_ARRAY(BytesRequired, 2, 102, Server)
  319. BUILD_LENGTH_ARRAY(BytesRequired, 2, 402, Server)
  320. //
  321. // If we're doing a level 3, Initialize the Level3_403_Length array with
  322. // the length of each string
  323. //
  324. if (Level == 3) {
  325. // Can't use the macro here, due to not really having a pLevel403
  326. // BUILD_LENGTH_ARRAY(BytesRequired, 3, 403, Server)
  327. //
  328. for (i = 0; NetpServer3_403[i].Source != MOVESTRING_END_MARKER; i++) {
  329. Level3_403_Length[i] =
  330. (DWORD) STRLEN(
  331. (LPVOID) *((LPTSTR*) (LPVOID)
  332. (((LPBYTE) (LPVOID) pLevel402)
  333. + NetpServer3_403[i].Source)) );
  334. BytesRequired += Level3_403_Length[i];
  335. }
  336. }
  337. //
  338. // Allocate the new buffer which will be returned to the user. Allocate
  339. // the space for a level 3 even if you only need level 2, it's only 12
  340. // bytes and it would take more than that in code to differentiate
  341. //
  342. ReturnCode =
  343. NetapipBufferAllocate(BytesRequired + sizeof(SERVER_INFO_3),
  344. (LPVOID *) ppLevel2);
  345. if (ReturnCode) {
  346. return(ERROR_NOT_ENOUGH_MEMORY);
  347. }
  348. //
  349. // First get the floor to start moving strings in at.
  350. //
  351. pFloor = (LPTSTR)((LPBYTE)*ppLevel2 + BytesRequired + sizeof(SERVER_INFO_2));
  352. //
  353. // Now move the variable length entries into the new buffer from both the
  354. // 102 and 402 data structures.
  355. //
  356. (VOID) NetpMoveStrings(
  357. &pFloor,
  358. (LPTSTR) (LPVOID) pLevel102,
  359. (LPVOID) *ppLevel2,
  360. NetpServer2_102,
  361. Level2_102_Length);
  362. (VOID) NetpMoveStrings(
  363. &pFloor,
  364. (LPTSTR) (LPVOID) pLevel402,
  365. (LPVOID) *ppLevel2,
  366. NetpServer2_402,
  367. Level2_402_Length);
  368. //
  369. // Now set the rest of the fields in the fixed length portion
  370. // of the structure
  371. //
  372. (*ppLevel2)->sv2_version_major = pLevel102->sv102_version_major;
  373. (*ppLevel2)->sv2_version_minor = pLevel102->sv102_version_minor;
  374. (*ppLevel2)->sv2_type = pLevel102->sv102_type;
  375. (*ppLevel2)->sv2_ulist_mtime = pLevel402->sv402_ulist_mtime;
  376. (*ppLevel2)->sv2_glist_mtime = pLevel402->sv402_glist_mtime;
  377. (*ppLevel2)->sv2_alist_mtime = pLevel402->sv402_alist_mtime;
  378. (*ppLevel2)->sv2_users = pLevel102->sv102_users;
  379. (*ppLevel2)->sv2_disc = pLevel102->sv102_disc;
  380. (*ppLevel2)->sv2_security = pLevel402->sv402_security;
  381. (*ppLevel2)->sv2_auditing = 0;
  382. (*ppLevel2)->sv2_numadmin = pLevel402->sv402_numadmin;
  383. (*ppLevel2)->sv2_lanmask = pLevel402->sv402_lanmask;
  384. (*ppLevel2)->sv2_hidden = (DWORD) pLevel102->sv102_hidden;
  385. (*ppLevel2)->sv2_announce = pLevel102->sv102_announce;
  386. (*ppLevel2)->sv2_anndelta = pLevel102->sv102_anndelta;
  387. (*ppLevel2)->sv2_licenses = pLevel102->sv102_licenses;
  388. (*ppLevel2)->sv2_chdevs = pLevel402->sv402_chdevs;
  389. (*ppLevel2)->sv2_chdevq = pLevel402->sv402_chdevq;
  390. (*ppLevel2)->sv2_chdevjobs = pLevel402->sv402_chdevjobs;
  391. (*ppLevel2)->sv2_connections = pLevel402->sv402_connections;
  392. (*ppLevel2)->sv2_shares = pLevel402->sv402_shares;
  393. (*ppLevel2)->sv2_openfiles = pLevel402->sv402_openfiles;
  394. (*ppLevel2)->sv2_sessopens = pLevel402->sv402_sessopens;
  395. (*ppLevel2)->sv2_sessvcs = pLevel402->sv402_sessvcs;
  396. (*ppLevel2)->sv2_sessreqs = pLevel402->sv402_sessreqs;
  397. (*ppLevel2)->sv2_opensearch = pLevel402->sv402_opensearch;
  398. (*ppLevel2)->sv2_activelocks = pLevel402->sv402_activelocks;
  399. (*ppLevel2)->sv2_numreqbuf = pLevel402->sv402_numreqbuf;
  400. (*ppLevel2)->sv2_sizreqbuf = pLevel402->sv402_sizreqbuf;
  401. (*ppLevel2)->sv2_numbigbuf = pLevel402->sv402_numbigbuf;
  402. (*ppLevel2)->sv2_numfiletasks = pLevel402->sv402_numfiletasks;
  403. (*ppLevel2)->sv2_alertsched = pLevel402->sv402_alertsched;
  404. (*ppLevel2)->sv2_erroralert = pLevel402->sv402_erroralert;
  405. (*ppLevel2)->sv2_logonalert = pLevel402->sv402_logonalert;
  406. (*ppLevel2)->sv2_accessalert = pLevel402->sv402_accessalert;
  407. (*ppLevel2)->sv2_diskalert = pLevel402->sv402_diskalert;
  408. (*ppLevel2)->sv2_netioalert = pLevel402->sv402_netioalert;
  409. (*ppLevel2)->sv2_maxauditsz = pLevel402->sv402_maxauditsz;
  410. //
  411. // If we're building a level 3, do the incremental fields
  412. //
  413. if (Level == 3) {
  414. //
  415. // Now finish up by moving in the level 3 stuff. This assumes that all
  416. // the offsets into the level 2 and level 3 structures are the same
  417. // except for the additional level 3 stuff
  418. //
  419. //
  420. // First the string
  421. //
  422. (VOID) NetpMoveStrings(
  423. &pFloor,
  424. (LPTSTR) (LPVOID) pLevel402,
  425. (LPVOID) *ppLevel2,
  426. NetpServer3_403,
  427. Level3_403_Length);
  428. //
  429. // Now the fixed length data
  430. //
  431. ((PSERVER_INFO_3) (LPVOID) (*ppLevel2))->sv3_auditedevents =
  432. ((PSERVER_INFO_403) (LPVOID) pLevel402)->sv403_auditedevents;
  433. ((PSERVER_INFO_3) (LPVOID) (*ppLevel2))->sv3_autoprofile =
  434. ((PSERVER_INFO_403) (LPVOID) pLevel402)->sv403_autoprofile;
  435. }
  436. return (NERR_Success);
  437. }
  438. NET_API_STATUS
  439. NetpMakeServerLevelForNT(
  440. IN DWORD Level,
  441. PSERVER_INFO_102 pLevel102,
  442. PSERVER_INFO_502 pLevel502,
  443. PSERVER_INFO_2 * ppLevel2
  444. )
  445. {
  446. DWORD BytesRequired = 0;
  447. NET_API_STATUS ReturnCode;
  448. DWORD Level2_102_Length[3];
  449. DWORD i;
  450. LPTSTR pFloor;
  451. //
  452. // Initialize the Level2_102_Length array with the length of each string
  453. // in the 102 buffer, and allocate the new buffer for SERVER_INFO_2
  454. //
  455. BUILD_LENGTH_ARRAY(BytesRequired, 2, 102, Server)
  456. //
  457. // Allocate the new buffer which will be returned to the user. Allocate
  458. // space for a level 3 just in case
  459. //
  460. ReturnCode = NetapipBufferAllocate(BytesRequired + sizeof(SERVER_INFO_3),
  461. (LPVOID *) ppLevel2);
  462. if (ReturnCode) {
  463. return(ERROR_NOT_ENOUGH_MEMORY);
  464. }
  465. //
  466. // First get the floor to start moving strings in at.
  467. //
  468. pFloor = (LPTSTR)((LPBYTE)*ppLevel2 + BytesRequired + sizeof(SERVER_INFO_3));
  469. //
  470. // Now move the variable length entries into the new buffer from the
  471. // 2 data structure.
  472. //
  473. (VOID) NetpMoveStrings(
  474. &pFloor,
  475. (LPTSTR) (LPVOID) pLevel102,
  476. (LPVOID) *ppLevel2,
  477. NetpServer2_102,
  478. Level2_102_Length);
  479. //
  480. // Clear string pointers in the level 2 structure for strings that
  481. // don't exist in NT.
  482. //
  483. (*ppLevel2)->sv2_alerts = NULL;
  484. (*ppLevel2)->sv2_guestacct = NULL;
  485. (*ppLevel2)->sv2_srvheuristics = NULL;
  486. //
  487. // Now set the rest of the fields in the fixed length portion
  488. // of the structure
  489. //
  490. (*ppLevel2)->sv2_version_major = pLevel102->sv102_version_major;
  491. (*ppLevel2)->sv2_version_minor = pLevel102->sv102_version_minor;
  492. (*ppLevel2)->sv2_type = pLevel102->sv102_type;
  493. (*ppLevel2)->sv2_users = pLevel102->sv102_users;
  494. (*ppLevel2)->sv2_disc = pLevel102->sv102_disc;
  495. (*ppLevel2)->sv2_hidden = (DWORD) pLevel102->sv102_hidden;
  496. (*ppLevel2)->sv2_announce = pLevel102->sv102_announce;
  497. (*ppLevel2)->sv2_anndelta = pLevel102->sv102_anndelta;
  498. (*ppLevel2)->sv2_licenses = pLevel102->sv102_licenses;
  499. (*ppLevel2)->sv2_sessopens = pLevel502->sv502_sessopens;
  500. (*ppLevel2)->sv2_sessvcs = pLevel502->sv502_sessvcs;
  501. (*ppLevel2)->sv2_opensearch = pLevel502->sv502_opensearch;
  502. (*ppLevel2)->sv2_sizreqbuf = pLevel502->sv502_sizreqbuf;
  503. (*ppLevel2)->sv2_ulist_mtime = DEF16_sv_ulist_mtime;
  504. (*ppLevel2)->sv2_glist_mtime = DEF16_sv_glist_mtime;
  505. (*ppLevel2)->sv2_alist_mtime = DEF16_sv_alist_mtime;
  506. (*ppLevel2)->sv2_security = SV_USERSECURITY;
  507. (*ppLevel2)->sv2_auditing = DEF16_sv_auditing;
  508. (*ppLevel2)->sv2_numadmin = (DWORD) DEF16_sv_numadmin;
  509. (*ppLevel2)->sv2_lanmask = DEF16_sv_lanmask;
  510. (*ppLevel2)->sv2_chdevs = DEF16_sv_chdevs;
  511. (*ppLevel2)->sv2_chdevq = DEF16_sv_chdevq;
  512. (*ppLevel2)->sv2_chdevjobs = DEF16_sv_chdevjobs;
  513. (*ppLevel2)->sv2_connections = DEF16_sv_connections;
  514. (*ppLevel2)->sv2_shares = DEF16_sv_shares;
  515. (*ppLevel2)->sv2_openfiles = DEF16_sv_openfiles;
  516. (*ppLevel2)->sv2_sessreqs = DEF16_sv_sessreqs;
  517. (*ppLevel2)->sv2_activelocks = DEF16_sv_activelocks;
  518. (*ppLevel2)->sv2_numreqbuf = DEF16_sv_numreqbuf;
  519. (*ppLevel2)->sv2_numbigbuf = DEF16_sv_numbigbuf;
  520. (*ppLevel2)->sv2_numfiletasks = DEF16_sv_numfiletasks;
  521. (*ppLevel2)->sv2_alertsched = DEF16_sv_alertsched;
  522. (*ppLevel2)->sv2_erroralert = DEF16_sv_erroralert;
  523. (*ppLevel2)->sv2_logonalert = DEF16_sv_logonalert;
  524. (*ppLevel2)->sv2_accessalert = DEF16_sv_accessalert;
  525. (*ppLevel2)->sv2_diskalert = DEF16_sv_diskalert;
  526. (*ppLevel2)->sv2_netioalert = DEF16_sv_netioalert;
  527. (*ppLevel2)->sv2_maxauditsz = DEF16_sv_maxauditsz;
  528. //
  529. // If we're building a level 3, do the incremental fields
  530. //
  531. if (Level == 3) {
  532. //
  533. // Now finish up by moving in the level 3 stuff. This assumes that all
  534. // the offsets into the level 2 and level 3 structures are the same
  535. // except for the additional level 3 stuff
  536. //
  537. //
  538. // First the string
  539. //
  540. ((PSERVER_INFO_3) (LPVOID) *ppLevel2)->sv3_autopath = NULL;
  541. //
  542. // Now the fixed length data
  543. //
  544. ((PSERVER_INFO_3) (LPVOID) (*ppLevel2))->sv3_auditedevents =
  545. DEF16_sv_auditedevents;
  546. ((PSERVER_INFO_3) (LPVOID) (*ppLevel2))->sv3_autoprofile =
  547. DEF16_sv_autoprofile;
  548. }
  549. return (NERR_Success);
  550. }
  551. NET_API_STATUS
  552. NetpSplitServerForNT(
  553. IN LPTSTR Server,
  554. IN DWORD Level,
  555. PSERVER_INFO_2 pLevel2,
  556. PSERVER_INFO_102 * ppLevel102,
  557. PSERVER_INFO_502 * ppLevel502
  558. )
  559. {
  560. DWORD BytesRequired = 0;
  561. NET_API_STATUS ReturnCode;
  562. DWORD Level102_2_Length[3];
  563. DWORD i;
  564. LPTSTR pFloor;
  565. UNREFERENCED_PARAMETER(Level);
  566. //
  567. // Initialize the Level102_2_Length array with the length of each string
  568. // in the 2 buffer
  569. //
  570. BUILD_LENGTH_ARRAY(BytesRequired, 102, 2, Server)
  571. //
  572. // Allocate the new 102 buffer which will be returned to the user
  573. //
  574. ReturnCode = NetapipBufferAllocate(BytesRequired + sizeof(SERVER_INFO_102),
  575. (LPVOID *) ppLevel102);
  576. if (ReturnCode) {
  577. return (ReturnCode);
  578. }
  579. //
  580. // First get the floor to start moving strings in at.
  581. //
  582. pFloor = (LPTSTR)((LPBYTE)*ppLevel102 + BytesRequired + sizeof(SERVER_INFO_102));
  583. //
  584. // Now move the variable length entries into the new buffer from the
  585. // level 2 data structure.
  586. //
  587. (VOID) NetpMoveStrings(
  588. &pFloor,
  589. (LPTSTR) (LPVOID) pLevel2,
  590. (LPVOID) *ppLevel102,
  591. NetpServer102_2,
  592. Level102_2_Length);
  593. //
  594. // Now let's do the same stuff for the 502 structure (except that there
  595. // are no variable length strings.
  596. //
  597. //
  598. // Get the current 502 information, and then lay the new information
  599. // over the top of it
  600. //
  601. ReturnCode = NetServerGetInfo(Server, 502, (LPBYTE *) (LPVOID) ppLevel502);
  602. if (ReturnCode) {
  603. return (ReturnCode);
  604. }
  605. //
  606. // Now set the rest of the fields in the fixed length portion
  607. // of the structure
  608. //
  609. (*ppLevel102)->sv102_version_major = pLevel2->sv2_version_major;
  610. (*ppLevel102)->sv102_version_minor = pLevel2->sv2_version_minor;
  611. (*ppLevel102)->sv102_type = pLevel2->sv2_type;
  612. (*ppLevel102)->sv102_users = pLevel2->sv2_users;
  613. (*ppLevel102)->sv102_disc = pLevel2->sv2_disc;
  614. (*ppLevel102)->sv102_hidden = (BOOL) pLevel2->sv2_hidden;
  615. (*ppLevel102)->sv102_announce = pLevel2->sv2_announce;
  616. (*ppLevel102)->sv102_anndelta = pLevel2->sv2_anndelta;
  617. (*ppLevel102)->sv102_licenses = pLevel2->sv2_licenses;
  618. (*ppLevel502)->sv502_sessopens = pLevel2->sv2_sessopens;
  619. (*ppLevel502)->sv502_sessvcs = pLevel2->sv2_sessvcs;
  620. (*ppLevel502)->sv502_opensearch = pLevel2->sv2_opensearch;
  621. (*ppLevel502)->sv502_sizreqbuf = pLevel2->sv2_sizreqbuf;
  622. return (NERR_Success);
  623. }