Source code of Windows XP (NT5)
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.

707 lines
18 KiB

  1. /*****************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /*****************************************************************/
  5. /*
  6. * History:
  7. * gregj 20-May-1991 Cloned from SERVER_ENUM
  8. * gregj 23-May-1991 Added LOCATION support
  9. * rustanl 18-Jul-1991 Added ( const LOCATION & ) constructors
  10. * KeithMo 07-Oct-1991 Win32 Conversion.
  11. * JonN 29-Jan-1992 Added resumable iterator
  12. * JonN 13-Mar-1992 Moved NT enumerator to lmoent.hxx
  13. * Yi-HsinS18-Sep-1992 Make USER_ENUM resumable.
  14. *
  15. */
  16. #ifndef _LMOEUSR_HXX_
  17. #define _LMOEUSR_HXX_
  18. #include "lmoersm.hxx"
  19. /**********************************************************\
  20. NAME: USER_ENUM
  21. SYNOPSIS: User enumeration class
  22. INTERFACE: See derived USERx_ENUM classes
  23. PARENT: LOC_LM_ENUM
  24. USES:
  25. HISTORY:
  26. gregj 20-May-1991 Cloned from SERVER_ENUM
  27. gregj 23-May-1991 Added LOCATION support
  28. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  29. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  30. \**********************************************************/
  31. DLL_CLASS USER_ENUM : public LOC_LM_RESUME_ENUM
  32. {
  33. private:
  34. NLS_STR _nlsGroupName;
  35. ULONG _ResumeHandle;
  36. virtual APIERR CallAPI( BOOL fRestartEnum,
  37. BYTE ** ppbBuffer,
  38. UINT * pcEntriesRead );
  39. protected:
  40. USER_ENUM ( const TCHAR * pszLocation,
  41. UINT level,
  42. const TCHAR * pszGroupName = NULL,
  43. BOOL fKeepBuffers = FALSE );
  44. USER_ENUM ( LOCATION_TYPE locType,
  45. UINT level,
  46. const TCHAR * pszGroupName = NULL,
  47. BOOL fKeepBuffers = FALSE );
  48. USER_ENUM ( const LOCATION & loc,
  49. UINT level,
  50. const TCHAR * pszGroupName = NULL,
  51. BOOL fKeepBuffers = FALSE );
  52. }; // class USER_ENUM
  53. /**********************************************************\
  54. NAME: USER0_ENUM
  55. SYNOPSIS: User enumeration, level 0
  56. INTERFACE:
  57. USER0_ENUM() - construct with location
  58. string or type, optional group name
  59. PARENT: USER_ENUM
  60. USES:
  61. CAVEATS: This assumes that the data structures used by
  62. NetUserEnum level 0 (user_info_0) and by
  63. NetGroupGetUsers (group_users_info_0) are
  64. identical. This assumption is asserted in
  65. the class definition.
  66. HISTORY:
  67. gregj 20-May-1991 Cloned from SERVER1_ENUM
  68. gregj 23-May-1991 Added LOCATION support
  69. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  70. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  71. \**********************************************************/
  72. DLL_CLASS USER0_ENUM : public USER_ENUM
  73. {
  74. public:
  75. USER0_ENUM( const TCHAR * pszLocation,
  76. const TCHAR * pszGroupName = NULL,
  77. BOOL fKeepBuffers = FALSE );
  78. USER0_ENUM( LOCATION_TYPE locType,
  79. const TCHAR * pszGroupName = NULL,
  80. BOOL fKeepBuffers = FALSE );
  81. USER0_ENUM( const LOCATION & loc,
  82. const TCHAR * pszGroupName = NULL,
  83. BOOL fKeepBuffers = FALSE );
  84. }; // class USER0_ENUM
  85. /*************************************************************************
  86. NAME: USER0_ENUM_OBJ
  87. SYNOPSIS: This is basically the return type from the USER0_ENUM_ITER
  88. iterator.
  89. INTERFACE: USER0_ENUM_OBJ - Class constructor.
  90. ~USER0_ENUM_OBJ - Class destructor.
  91. QueryBufferPtr - Replaces ENUM_OBJ_BASE method.
  92. QueryName - Returns the user name.
  93. PARENT: ENUM_OBJ_BASE
  94. HISTORY:
  95. KeithMo 07-Oct-1991 Created.
  96. **************************************************************************/
  97. DLL_CLASS USER0_ENUM_OBJ : public ENUM_OBJ_BASE
  98. {
  99. public:
  100. //
  101. // Provide properly-casted buffer Query/Set methods.
  102. //
  103. DECLARE_ENUM_BUFFER_METHODS( struct user_info_0 );
  104. //
  105. // Accessors.
  106. //
  107. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, usri0_name );
  108. }; // class USER0_ENUM_OBJ
  109. DECLARE_LM_RESUME_ENUM_ITER_OF( USER0, struct user_info_0 );
  110. /**********************************************************\
  111. NAME: USER1_ENUM
  112. SYNOPSIS: User enumeration, level 1
  113. INTERFACE:
  114. USER1_ENUM() - construct with location string
  115. or type code
  116. PARENT: USER_ENUM
  117. USES:
  118. HISTORY:
  119. gregj 20-May-1991 Cloned from SERVER1_ENUM
  120. gregj 23-May-1991 Added LOCATION support
  121. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  122. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  123. \**********************************************************/
  124. DLL_CLASS USER1_ENUM : public USER_ENUM
  125. {
  126. public:
  127. USER1_ENUM( const TCHAR * pszLocation,
  128. BOOL fKeepBuffers = FALSE );
  129. USER1_ENUM( LOCATION_TYPE locType,
  130. BOOL fKeepBuffers = FALSE );
  131. USER1_ENUM( const LOCATION & loc,
  132. BOOL fKeepBuffers = FALSE );
  133. }; // class USER1_ENUM
  134. /*************************************************************************
  135. NAME: USER1_ENUM_OBJ
  136. SYNOPSIS: This is basically the return type from the USER1_ENUM_ITER
  137. iterator.
  138. INTERFACE: USER1_ENUM_OBJ - Class constructor.
  139. ~USER1_ENUM_OBJ - Class destructor.
  140. QueryBufferPtr - Replaces ENUM_OBJ_BASE method.
  141. QueryName - Returns the user name.
  142. QueryPasswordAge - Returns the password age.
  143. QueryPriv - Returns privilege information.
  144. QueryHomeDir - Returns the user's home directory.
  145. QueryComment - Returns the comment.
  146. QueryFlags - Returns the user flags.
  147. QueryScriptPath - Returns the user's script path.
  148. PARENT: ENUM_OBJ_BASE
  149. HISTORY:
  150. KeithMo 07-Oct-1991 Created.
  151. **************************************************************************/
  152. DLL_CLASS USER1_ENUM_OBJ : public ENUM_OBJ_BASE
  153. {
  154. public:
  155. //
  156. // Provide properly-casted buffer Query/Set methods.
  157. //
  158. DECLARE_ENUM_BUFFER_METHODS( struct user_info_1 );
  159. //
  160. // Accessors.
  161. //
  162. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, usri1_name);
  163. DECLARE_ENUM_ACCESSOR( QueryPasswordAge, ULONG, usri1_password_age);
  164. DECLARE_ENUM_ACCESSOR( QueryPriv, UINT, usri1_priv);
  165. DECLARE_ENUM_ACCESSOR( QueryHomeDir, const TCHAR *, usri1_home_dir);
  166. DECLARE_ENUM_ACCESSOR( QueryComment, const TCHAR *, usri1_comment);
  167. DECLARE_ENUM_ACCESSOR( QueryFlags, UINT, usri1_flags);
  168. DECLARE_ENUM_ACCESSOR( QueryScriptPath, const TCHAR *, usri1_script_path);
  169. }; // class USER1_ENUM_OBJ
  170. DECLARE_LM_RESUME_ENUM_ITER_OF( USER1, struct user_info_1 );
  171. /**********************************************************\
  172. NAME: USER2_ENUM
  173. SYNOPSIS: User enumeration, level 2
  174. INTERFACE:
  175. USER2_ENUM() - construct with location string
  176. or type code
  177. PARENT: USER_ENUM
  178. USES:
  179. HISTORY:
  180. gregj 20-May-1991 Cloned from SERVER1_ENUM
  181. gregj 23-May-1991 Added LOCATION support
  182. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  183. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  184. \**********************************************************/
  185. DLL_CLASS USER2_ENUM : public USER_ENUM
  186. {
  187. public:
  188. USER2_ENUM( const TCHAR * pszLocation,
  189. BOOL fKeepBuffers = FALSE );
  190. USER2_ENUM( LOCATION_TYPE locType,
  191. BOOL fKeepBuffers = FALSE );
  192. USER2_ENUM( const LOCATION & loc,
  193. BOOL fKeepBuffers = FALSE );
  194. }; // class USER2_ENUM
  195. /*************************************************************************
  196. NAME: USER2_ENUM_OBJ
  197. SYNOPSIS: This is basically the return type from the USER2_ENUM_ITER
  198. iterator.
  199. INTERFACE: USER2_ENUM_OBJ - Class constructor.
  200. ~USER2_ENUM_OBJ - Class destructor.
  201. QueryBufferPtr - Replaces ENUM_OBJ_BASE method.
  202. QueryName - Returns the user name.
  203. QueryPasswordAge - Returns the password age.
  204. QueryPriv - Returns privilege information.
  205. QueryHomeDir - Returns the user's home directory.
  206. QueryComment - Returns the comment.
  207. QueryFlags - Returns the user flags.
  208. QueryScriptPath - Returns the user's script path.
  209. QueryAuthFlags - Returns the authorization flags.
  210. QueryFullName - Returns the user's full name.
  211. QueryUserComment - Returns the user comment.
  212. QueryParms - Returns the application parameters.
  213. QueryWorkstations - Returns the names of the workstations
  214. that the user can log into.
  215. QueryLastLogon - Returns the time of last logon.
  216. QueryLastLogoff - Returns the time of last logoff.
  217. QueryAccountExpires - Returns the account expiration date.
  218. QueryMaxStorage - Returns the user's disk space quota.
  219. QueryUnitsPerWeek - ?
  220. QueryLogonHours - Returns the allowed logon hours.
  221. QueryBadPWCount - Returns the number of attempts to
  222. log into this account with a bad
  223. password.
  224. QueryNumLogons - Returns the number of successful
  225. logon attempts for this account.
  226. QueryLogonServer - Returns the logon server.
  227. QueryCountryCode - Returns the country code for this
  228. user.
  229. QueryCodePage - Returns the code page for this user.
  230. PARENT: ENUM_OBJ_BASE
  231. HISTORY:
  232. KeithMo 07-Oct-1991 Created.
  233. **************************************************************************/
  234. DLL_CLASS USER2_ENUM_OBJ : public ENUM_OBJ_BASE
  235. {
  236. public:
  237. //
  238. // Provide properly-casted buffer Query/Set methods.
  239. //
  240. DECLARE_ENUM_BUFFER_METHODS( struct user_info_2 );
  241. //
  242. // Accessors.
  243. //
  244. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, usri2_name );
  245. DECLARE_ENUM_ACCESSOR( QueryPasswordAge, ULONG, usri2_password_age );
  246. DECLARE_ENUM_ACCESSOR( QueryPriv, UINT, usri2_priv );
  247. DECLARE_ENUM_ACCESSOR( QueryHomeDir, const TCHAR *, usri2_home_dir );
  248. DECLARE_ENUM_ACCESSOR( QueryComment, const TCHAR *, usri2_comment );
  249. DECLARE_ENUM_ACCESSOR( QueryFlags, UINT, usri2_flags );
  250. DECLARE_ENUM_ACCESSOR( QueryScriptPath, const TCHAR *, usri2_script_path );
  251. DECLARE_ENUM_ACCESSOR( QueryAuthFlags, ULONG, usri2_auth_flags );
  252. DECLARE_ENUM_ACCESSOR( QueryFullName, const TCHAR *, usri2_full_name );
  253. DECLARE_ENUM_ACCESSOR( QueryUserComment, const TCHAR *, usri2_usr_comment );
  254. DECLARE_ENUM_ACCESSOR( QueryParms, const TCHAR *, usri2_parms );
  255. DECLARE_ENUM_ACCESSOR( QueryWorkstations,const TCHAR *, usri2_workstations );
  256. DECLARE_ENUM_ACCESSOR( QueryLastLogon, LONG, usri2_last_logon );
  257. DECLARE_ENUM_ACCESSOR( QueryLastLogoff, LONG, usri2_last_logoff );
  258. DECLARE_ENUM_ACCESSOR( QueryAccountExpires,LONG, usri2_acct_expires );
  259. DECLARE_ENUM_ACCESSOR( QueryMaxStorage, ULONG, usri2_max_storage );
  260. DECLARE_ENUM_ACCESSOR( QueryUnitsPerWeek,UINT, usri2_units_per_week );
  261. DECLARE_ENUM_ACCESSOR( QueryBadPWCount, UINT, usri2_bad_pw_count );
  262. DECLARE_ENUM_ACCESSOR( QueryNumLogons, UINT, usri2_num_logons );
  263. DECLARE_ENUM_ACCESSOR( QueryLogonServer, const TCHAR *, usri2_logon_server );
  264. DECLARE_ENUM_ACCESSOR( QueryCountryCode, UINT, usri2_country_code );
  265. DECLARE_ENUM_ACCESSOR( QueryCodePage, UINT, usri2_code_page );
  266. }; // class USER2_ENUM_OBJ
  267. DECLARE_LM_RESUME_ENUM_ITER_OF( USER2, struct user_info_2 );
  268. /**********************************************************\
  269. NAME: USER10_ENUM
  270. SYNOPSIS: User enumeration, level 10
  271. INTERFACE:
  272. USER10_ENUM() - construct with location string
  273. or type code
  274. PARENT: USER_ENUM
  275. USES:
  276. HISTORY:
  277. gregj 20-May-1991 Cloned from SERVER1_ENUM
  278. gregj 23-May-1991 Added LOCATION support
  279. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  280. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  281. \**********************************************************/
  282. DLL_CLASS USER10_ENUM : public USER_ENUM
  283. {
  284. public:
  285. USER10_ENUM( const TCHAR * pszLocation,
  286. BOOL fKeepBuffers = FALSE );
  287. USER10_ENUM( LOCATION_TYPE locType,
  288. BOOL fKeepBuffers = FALSE );
  289. USER10_ENUM( const LOCATION & loc,
  290. BOOL fKeepBuffers = FALSE );
  291. }; // class USER10_ENUM
  292. /*************************************************************************
  293. NAME: USER10_ENUM_OBJ
  294. SYNOPSIS: This is basically the return type from the USER10_ENUM_ITER
  295. iterator.
  296. INTERFACE: USER10_ENUM_OBJ - Class constructor.
  297. ~USER10_ENUM_OBJ - Class destructor.
  298. QueryBufferPtr - Replaces ENUM_OBJ_BASE method.
  299. QueryName - Returns the user name.
  300. QueryComment - Returns the comment.
  301. QueryUserComment - Returns the user comment.
  302. QueryFullName - Returns the user's full name.
  303. PARENT: ENUM_OBJ_BASE
  304. HISTORY:
  305. KeithMo 07-Oct-1991 Created.
  306. **************************************************************************/
  307. DLL_CLASS USER10_ENUM_OBJ : public ENUM_OBJ_BASE
  308. {
  309. public:
  310. //
  311. // Provide properly-casted buffer Query/Set methods.
  312. //
  313. DECLARE_ENUM_BUFFER_METHODS( struct user_info_10 );
  314. //
  315. // Accessors.
  316. //
  317. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, usri10_name);
  318. DECLARE_ENUM_ACCESSOR( QueryComment, const TCHAR *, usri10_comment);
  319. DECLARE_ENUM_ACCESSOR( QueryUserComment, const TCHAR *, usri10_usr_comment);
  320. DECLARE_ENUM_ACCESSOR( QueryFullName, const TCHAR *, usri10_full_name);
  321. }; // class USER10_ENUM_OBJ
  322. DECLARE_LM_RESUME_ENUM_ITER_OF( USER10, struct user_info_10 );
  323. /************************ GROUPS ************************/
  324. /**********************************************************\
  325. NAME: GROUP_ENUM
  326. SYNOPSIS: Group enumeration class
  327. INTERFACE: See derived GROUPx_ENUM classes
  328. PARENT: LOC_LM_ENUM
  329. HISTORY:
  330. gregj 21-May-1991 Cloned from USER_ENUM
  331. gregj 23-May-1991 Added LOCATION support
  332. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  333. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  334. \**********************************************************/
  335. DLL_CLASS GROUP_ENUM : public LOC_LM_ENUM
  336. {
  337. private:
  338. const TCHAR * _pszUserName;
  339. virtual APIERR CallAPI( BYTE ** ppbBuffer,
  340. UINT * pcEntriesRead );
  341. protected:
  342. GROUP_ENUM ( const TCHAR * pszLocation,
  343. UINT level,
  344. const TCHAR * pszUserName = NULL );
  345. GROUP_ENUM ( LOCATION_TYPE locType,
  346. UINT level,
  347. const TCHAR * pszUserName = NULL );
  348. GROUP_ENUM ( const LOCATION & loc,
  349. UINT level,
  350. const TCHAR * pszUserName = NULL );
  351. }; // class GROUP_ENUM
  352. /**********************************************************\
  353. NAME: GROUP0_ENUM
  354. SYNOPSIS: Group enumeration, level 0
  355. INTERFACE:
  356. GROUP0_ENUM() - construct with location string
  357. or type code, optional user name
  358. PARENT: GROUP_ENUM
  359. HISTORY:
  360. gregj 21-May-1991 Cloned from USER1_ENUM
  361. gregj 23-May-1991 Added LOCATION support
  362. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  363. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  364. \**********************************************************/
  365. DLL_CLASS GROUP0_ENUM : public GROUP_ENUM
  366. {
  367. public:
  368. GROUP0_ENUM( const TCHAR * pszLocation,
  369. const TCHAR * pszUserName = NULL );
  370. GROUP0_ENUM( LOCATION_TYPE locType,
  371. const TCHAR * pszUserName = NULL );
  372. GROUP0_ENUM( const LOCATION & loc,
  373. const TCHAR * pszUserName = NULL );
  374. }; // class GROUP0_ENUM
  375. /*************************************************************************
  376. NAME: GROUP0_ENUM_OBJ
  377. SYNOPSIS: This is basically the return type from the GROUP0_ENUM_ITER
  378. iterator.
  379. INTERFACE: GROUP0_ENUM_OBJ - Class constructor.
  380. ~GROUP0_ENUM_OBJ - Class destructor.
  381. QueryBufferPtr - Replaces ENUM_OBJ_BASE method.
  382. QueryName - Returns the group name.
  383. PARENT: ENUM_OBJ_BASE
  384. HISTORY:
  385. KeithMo 07-Oct-1991 Created.
  386. **************************************************************************/
  387. DLL_CLASS GROUP0_ENUM_OBJ : public ENUM_OBJ_BASE
  388. {
  389. public:
  390. //
  391. // Provide properly-casted buffer Query/Set methods.
  392. //
  393. const struct group_info_0 * QueryBufferPtr( VOID ) const
  394. { return (const struct group_info_0 *)ENUM_OBJ_BASE::QueryBufferPtr(); }
  395. VOID SetBufferPtr( const struct group_info_0 * pBuffer );
  396. //
  397. // Accessors.
  398. //
  399. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, grpi0_name );
  400. }; // class GROUP0_ENUM_OBJ
  401. DECLARE_LM_ENUM_ITER_OF( GROUP0, struct group_info_0 );
  402. /**********************************************************\
  403. NAME: GROUP1_ENUM
  404. SYNOPSIS: Group enumeration, level 1
  405. INTERFACE:
  406. GROUP1_ENUM() - construct with location string
  407. or type code
  408. PARENT: GROUP_ENUM
  409. HISTORY:
  410. gregj 21-May-1991 Cloned from USER1_ENUM
  411. gregj 23-May-1991 Added LOCATION support
  412. rustanl 18-Jul-1991 Added ( const LOCATION & ) constructor
  413. KeithMo 07-Oct-1991 Changed all USHORTs to UINTs.
  414. \**********************************************************/
  415. DLL_CLASS GROUP1_ENUM : public GROUP_ENUM
  416. {
  417. public:
  418. GROUP1_ENUM( const TCHAR * pszLocation );
  419. GROUP1_ENUM( LOCATION_TYPE locType );
  420. GROUP1_ENUM( const LOCATION & loc );
  421. }; // class GROUP1_ENUM
  422. /*************************************************************************
  423. NAME: GROUP1_ENUM_OBJ
  424. SYNOPSIS: This is basically the return type from the GROUP1_ENUM_ITER
  425. iterator.
  426. INTERFACE: GROUP1_ENUM_OBJ - Class constructor.
  427. ~GROUP1_ENUM_OBJ - Class destructor.
  428. QueryBufferPtr - Replaces ENUM_OBJ_BASE method.
  429. QueryName - Returns the group name.
  430. QueryComment - Returns the group comment.
  431. PARENT: ENUM_OBJ_BASE
  432. HISTORY:
  433. KeithMo 07-Oct-1991 Created.
  434. **************************************************************************/
  435. DLL_CLASS GROUP1_ENUM_OBJ : public ENUM_OBJ_BASE
  436. {
  437. public:
  438. //
  439. // Provide properly-casted buffer Query/Set methods.
  440. //
  441. const struct group_info_1 * QueryBufferPtr( VOID ) const
  442. { return (const struct group_info_1 *)ENUM_OBJ_BASE::QueryBufferPtr(); }
  443. VOID SetBufferPtr( const struct group_info_1 * pBuffer );
  444. //
  445. // Accessors.
  446. //
  447. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, grpi1_name );
  448. DECLARE_ENUM_ACCESSOR( QueryComment, const TCHAR *, grpi1_comment );
  449. }; // class GROUP1_ENUM_OBJ
  450. DECLARE_LM_ENUM_ITER_OF( GROUP1, struct group_info_1 );
  451. #endif // _LMOEUSR_HXX_