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.

272 lines
9.5 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. WksStInf.c
  5. Abstract:
  6. This module only contains RxNetWkstaSetInfo.
  7. Author:
  8. John Rogers (JohnRo) 19-Aug-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 19-Aug-1991 JohnRo
  14. Implement downlevel NetWksta APIs.
  15. 21-Nov-1991 JohnRo
  16. Removed NT dependencies to reduce recompiles.
  17. 07-Feb-1992 JohnRo
  18. Use NetApiBufferAllocate() instead of private version.
  19. 02-Apr-1992 JohnRo
  20. Fixed bug in setinfo of level 402 (was causing GP fault in strlen).
  21. 03-Nov-1992 JohnRo
  22. RAID 10418: NetWkstaGetInfo level 302: wrong error code.
  23. Use PREFIX_ equates.
  24. --*/
  25. // These must be included first:
  26. #include <windef.h> // IN, DWORD, etc.
  27. #include <lmcons.h>
  28. #include <rap.h> // LPDESC, etc. (Needed by <rxwksta.h>)
  29. // These may be included in any order:
  30. #include <apinums.h> // API_ equates.
  31. #include <dlwksta.h> // NetpConvertWkstaInfo().
  32. #include <lmapibuf.h> // NetApiBufferAllocate(), NetApiBufferFree().
  33. #include <lmerr.h> // NERR_ and ERROR_ equates.
  34. #include <lmwksta.h> // Wksta parmnum equates.
  35. #include <netdebug.h> // NetpAssert(), FORMAT_ equates, etc.
  36. #include <netlib.h> // NetpSetParmError().
  37. #include <prefix.h> // PREFIX_ equates.
  38. #include <remdef.h>
  39. #include <rx.h> // RxRemoteApi().
  40. #include <rxp.h> // RxpSetField().
  41. #include <rxpdebug.h> // IF_DEBUG().
  42. #include <rxwksta.h> // My prototype, etc.
  43. #include <strucinf.h> // NetpWkstaStructureInfo().
  44. NET_API_STATUS
  45. RxNetWkstaSetInfo (
  46. IN LPTSTR UncServerName,
  47. IN DWORD Level, // New style level or parmnum.
  48. IN LPBYTE Buf,
  49. OUT LPDWORD ParmError OPTIONAL // name required by NetpSetParmError macro.
  50. )
  51. /*++
  52. Routine Description:
  53. RxNetWkstaSetInfo performs the same function as NetWkstaSetInfo,
  54. except that the server name is known to refer to a downlevel server.
  55. Arguments:
  56. (Same as NetWkstaSetInfo, except UncServerName must not be null, and
  57. must not refer to the local computer.)
  58. Return Value:
  59. (Same as NetWkstaSetInfo.)
  60. --*/
  61. {
  62. BOOL IncompleteOutput;
  63. LPDESC EquivDataDesc16;
  64. LPDESC EquivDataDesc32;
  65. LPDESC EquivDataDescSmb;
  66. DWORD EquivLevel;
  67. DWORD EquivFixedSize;
  68. DWORD EquivMaxNativeSize;
  69. DWORD EquivStringSize;
  70. DWORD NewLevelOnly;
  71. NET_API_STATUS Status;
  72. // It's easiest to assume failure, and correct that assumption later.
  73. NetpSetParmError( PARM_ERROR_UNKNOWN );
  74. NetpAssert(UncServerName != NULL);
  75. if (Level > PARMNUM_BASE_INFOLEVEL) {
  76. NewLevelOnly = 402; // Only settable (new) level.
  77. } else if (Level == PARMNUM_BASE_INFOLEVEL) {
  78. return (ERROR_INVALID_LEVEL);
  79. } else {
  80. NewLevelOnly = Level;
  81. }
  82. if (NewLevelOnly != 402) {
  83. return (ERROR_INVALID_LEVEL);
  84. }
  85. //
  86. // Need lots of data on the requested info level and the equivalent
  87. // old info level...
  88. //
  89. Status = RxpGetWkstaInfoLevelEquivalent(
  90. NewLevelOnly, // from level
  91. & EquivLevel, // to level
  92. & IncompleteOutput); // is output not fully in input?
  93. NetpAssert(Status == NERR_Success); // Already checked NewLevelOnly!
  94. NetpAssert( NetpIsOldWkstaInfoLevel( EquivLevel ) );
  95. Status = NetpWkstaStructureInfo (
  96. EquivLevel,
  97. PARMNUM_ALL,
  98. TRUE, // want native sizes
  99. & EquivDataDesc16,
  100. & EquivDataDesc32,
  101. & EquivDataDescSmb,
  102. & EquivMaxNativeSize, // max native size of to level
  103. & EquivFixedSize, // to fixed size
  104. & EquivStringSize); // to string size
  105. NetpAssert(Status == NERR_Success); // Already checked NewLevelOnly!
  106. //
  107. // Depending on Level, either we're setting the entire thing, or just
  108. // one field.
  109. //
  110. if ( Level < PARMNUM_BASE_INFOLEVEL ) { // Setting entire structure.
  111. LPWKSTA_INFO_1 Dest;
  112. LPVOID EquivInfo; // Ptr to native "old" info.
  113. DWORD EquivActualSize32;
  114. LPWKSTA_INFO_402 Src;
  115. if ( Buf == NULL )
  116. return ERROR_INVALID_PARAMETER;
  117. NetpAssert( IncompleteOutput == FALSE );
  118. NetpAssert( NewLevelOnly == 402 ); // Assumed below.
  119. NetpAssert( EquivLevel == 1 ); // Assumed below.
  120. // Have all the data we need, so alloc memory for conversion.
  121. Status = NetApiBufferAllocate( EquivMaxNativeSize, & EquivInfo );
  122. if (Status != NERR_Success) {
  123. return (Status);
  124. }
  125. Dest = EquivInfo;
  126. Src = (LPVOID) Buf;
  127. // Convert caller's Wksta info to an info level understood by
  128. // downlevel.
  129. //
  130. // Note that this code takes advantage of the fact that a downlevel
  131. // server doesn't really set all of the fields just because we send
  132. // an entire structure. The server just sets the settable fields
  133. // from that structure. And the settable fields are defined by
  134. // the parmnums we can set. So, we don't bother copying all of
  135. // the fields here. (DanHi says this is OK.) --JohnRo 26-May-1991
  136. //
  137. // Also, when we do strings like this, we just point from one buffer
  138. // to the other buffer.
  139. //
  140. Dest->wki1_charwait = Src->wki402_char_wait;
  141. Dest->wki1_chartime = Src->wki402_collection_time;
  142. Dest->wki1_charcount = Src->wki402_maximum_collection_count;
  143. Dest->wki1_errlogsz = Src->wki402_errlog_sz;
  144. Dest->wki1_printbuftime = Src->wki402_print_buf_time;
  145. Dest->wki1_wrkheuristics = Src->wki402_wrk_heuristics;
  146. //
  147. // Just 'cos we're paranoid, let's set any "nonsettable" pointers to
  148. // NULL so RapConvertSingleEntry (for instance) doesn't GP fault.
  149. //
  150. Dest->wki1_root = NULL;
  151. Dest->wki1_computername = NULL;
  152. Dest->wki1_username = NULL;
  153. Dest->wki1_langroup = NULL;
  154. Dest->wki1_logon_server = NULL;
  155. Dest->wki1_logon_domain = NULL;
  156. Dest->wki1_oth_domains = NULL;
  157. NetpAssert( EquivInfo != NULL );
  158. EquivActualSize32 = RapTotalSize(
  159. EquivInfo, // in struct
  160. EquivDataDesc32, // in desc
  161. EquivDataDesc32, // out desc
  162. FALSE, // no meaningless input ptrs
  163. Both, // transmission mode
  164. NativeToNative); // conversion mode
  165. IF_DEBUG(WKSTA) {
  166. NetpKdPrint(( PREFIX_NETAPI
  167. "RxNetWkstaSetInfo(all): equiv actual size (32) is "
  168. FORMAT_DWORD ".\n", EquivActualSize32 ));
  169. }
  170. NetpAssert( EquivActualSize32 <= EquivMaxNativeSize );
  171. //
  172. // Remote the API to set the entire structure.
  173. //
  174. Status = RxRemoteApi(
  175. API_WWkstaSetInfo, // api num
  176. UncServerName,
  177. REMSmb_NetWkstaSetInfo_P, // parm desc (SMB version)
  178. EquivDataDesc16,
  179. EquivDataDesc32,
  180. EquivDataDescSmb,
  181. NULL, // no aux desc 16
  182. NULL, // no aux desc 32
  183. NULL, // no aux desc SMB
  184. FALSE, // not a null perm req API
  185. // rest of API's arguments in 32-bit, native, LM 2.x format:
  186. EquivLevel,
  187. EquivInfo,
  188. EquivActualSize32,
  189. (DWORD) PARMNUM_ALL);
  190. (void) NetApiBufferFree( EquivInfo );
  191. if (Status == NERR_Success) {
  192. NetpSetParmError(PARM_ERROR_NONE);
  193. } else {
  194. NetpSetParmError(PARM_ERROR_UNKNOWN);
  195. }
  196. } else {
  197. //
  198. // Just setting one field.
  199. //
  200. DWORD ParmNum = Level - PARMNUM_BASE_INFOLEVEL;
  201. NetpAssert( ParmNum > 0 );
  202. NetpAssert( ParmNum < 100 );
  203. NetpAssert( EquivLevel == 1 ); // Need level 1 for oth_domains.
  204. // ParmNum indicates only one field, so set it.
  205. Status = RxpSetField(
  206. API_WWkstaSetInfo, // api number
  207. UncServerName,
  208. NULL, // no specific object (dest)
  209. NULL, // no specific object to set
  210. REMSmb_NetWkstaSetInfo_P, // parm desc (SMB version)
  211. EquivDataDesc16, // data desc 16
  212. EquivDataDesc32, // data desc 32
  213. EquivDataDescSmb, // data desc SMB version
  214. Buf, // native (old) info buffer
  215. ParmNum, // parm num to send
  216. ParmNum, // field index (same)
  217. EquivLevel); // old info level
  218. if (Status == ERROR_INVALID_PARAMETER) {
  219. NetpAssert( Level > PARMNUM_BASE_INFOLEVEL );
  220. NetpSetParmError(Level);
  221. }
  222. }
  223. return (Status);
  224. }