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.

1798 lines
44 KiB

  1. package Win32API::Net;
  2. use strict;
  3. use Carp;
  4. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
  5. require Exporter;
  6. require DynaLoader;
  7. @ISA = qw(Exporter DynaLoader);
  8. # Items to export into callers namespace by default. Note: do not export
  9. # names by default without a very good reason. Use EXPORT_OK instead.
  10. # Do not simply export all your public functions/methods/constants.
  11. @EXPORT = qw(); # don't pollute callees namespace
  12. %EXPORT_TAGS=(
  13. User => [ qw(
  14. FILTER_INTERDOMAIN_TRUST_ACCOUNT FILTER_NORMAL_ACCOUNT
  15. FILTER_SERVER_TRUST_ACCOUNT FILTER_TEMP_DUPLICATE_ACCOUNTS
  16. FILTER_WORKSTATION_TRUST_ACCOUNT
  17. USER_ACCT_EXPIRES_PARMNUM USER_AUTH_FLAGS_PARMNUM
  18. USER_CODE_PAGE_PARMNUM USER_COMMENT_PARMNUM USER_COUNTRY_CODE_PARMNUM
  19. USER_FLAGS_PARMNUM USER_FULL_NAME_PARMNUM USER_HOME_DIR_DRIVE_PARMNUM
  20. USER_HOME_DIR_PARMNUM USER_LAST_LOGOFF_PARMNUM USER_LAST_LOGON_PARMNUM
  21. USER_LOGON_HOURS_PARMNUM USER_LOGON_SERVER_PARMNUM
  22. USER_MAX_STORAGE_PARMNUM USER_NAME_PARMNUM USER_NUM_LOGONS_PARMNUM
  23. USER_PAD_PW_COUNT_PARMNUM USER_PARMS_PARMNUM USER_PASSWORD_AGE_PARMNUM
  24. USER_PASSWORD_PARMNUM USER_PRIMARY_GROUP_PARMNUM USER_PRIV_ADMIN
  25. USER_PRIV_GUEST USER_PRIV_MASK USER_PRIV_PARMNUM USER_PRIV_USER
  26. USER_PROFILE_PARMNUM USER_PROFILE_PARMNUM USER_SCRIPT_PATH_PARMNUM
  27. USER_UNITS_PER_WEEK_PARMNUM USER_USR_COMMENT_PARMNUM
  28. USER_WORKSTATIONS_PARMNUM USER_BAD_PW_COUNT_PARMNUM LG_INCLUDE_INDIRECT
  29. UF_ACCOUNTDISABLE UF_ACCOUNT_TYPE_MASK UF_DONT_EXPIRE_PASSWD
  30. UF_HOMEDIR_REQUIRED UF_INTERDOMAIN_TRUST_ACCOUNT UF_LOCKOUT
  31. UF_MACHINE_ACCOUNT_MASK UF_NORMAL_ACCOUNT UF_PASSWD_CANT_CHANGE
  32. UF_PASSWD_NOTREQD UF_SCRIPT UF_SERVER_TRUST_ACCOUNT UF_SETTABLE_BITS
  33. UF_TEMP_DUPLICATE_ACCOUNT UF_WORKSTATION_TRUST_ACCOUNT
  34. UserAdd UserChangePassword UserDel UserEnum UserGetGroups UserGetInfo
  35. UserGetLocalGroups UserModalsGet UserModalsSet UserSetGroups
  36. UserSetInfo
  37. )],
  38. Get => [ qw(
  39. GetDCName
  40. )],
  41. Group => [ qw(
  42. GROUP_ATTRIBUTES_PARMNUM GROUP_COMMENT_PARMNUM GROUP_NAME_PARMNUM
  43. GroupAdd GroupAddUser GroupDel GroupDelUser GroupEnum GroupGetInfo
  44. GroupGetUsers GroupSetInfo GroupSetUsers
  45. )],
  46. LocalGroup => [ qw(
  47. LOCALGROUP_COMMENT_PARMNUM LOCALGROUP_NAME_PARMNUM
  48. LocalGroupAdd LocalGroupAddMember LocalGroupAddMembers LocalGroupDel
  49. LocalGroupDelMember LocalGroupDelMembers LocalGroupEnum
  50. LocalGroupGetInfo LocalGroupGetMembers LocalGroupSetInfo
  51. LocalGroupSetMembers
  52. )],
  53. );
  54. @EXPORT_OK= ();
  55. { my $ref;
  56. foreach $ref ( values(%EXPORT_TAGS) ) {
  57. push( @EXPORT_OK, @$ref );
  58. }
  59. }
  60. $EXPORT_TAGS{ALL}= \@EXPORT_OK;
  61. $VERSION = '0.07';
  62. sub AUTOLOAD {
  63. my $constname;
  64. ($constname = $AUTOLOAD) =~ s/.*:://;
  65. my $val = constant($constname, @_ ? $_[0] : 0);
  66. if ($! != 0) {
  67. if ($! =~ /Invalid/) {
  68. $AutoLoader::AUTOLOAD = $AUTOLOAD;
  69. goto &AutoLoader::AUTOLOAD;
  70. }
  71. else {
  72. croak "Your vendor has not defined Win32API::Net macro $constname";
  73. }
  74. }
  75. eval "sub $AUTOLOAD { $val }";
  76. goto &$AUTOLOAD;
  77. }
  78. bootstrap Win32API::Net $VERSION;
  79. 1;
  80. __END__
  81. =head1 NAME
  82. Win32API::Net - Perl interface to the Windows NT LanManager API account management functions.
  83. =head1 SYNOPSIS
  84. use Win32API::Net;
  85. =head1 DESCRIPTION
  86. Win32API::Net provides a more complete wrapper for the account management
  87. parts of the NT LanManager API than do other similar packages. Most of what
  88. you can achieve with the native C++ API is possible with this package - albeit
  89. in a more Perl like manner by using references to pass information to and
  90. from functions.
  91. For an understanding of the environment in which these functions operate see
  92. L<DATA STRUCTURES>.
  93. The following groups of functions are available:
  94. =over 8
  95. =item L<NET USER FUNCTIONS>
  96. =item L<NET GROUP FUNCTIONS>
  97. =item L<NET LOCAL GROUP FUNCTIONS>
  98. =item L<NET GET FUNCTIONS>
  99. =back
  100. All functions return 0 on failure and 1 on success. Use the
  101. C<Win32::GetLastError()> function to find out more information on why a
  102. function failed. In addition, some functions that take a hash reference
  103. to pass information in (e.g. C<UserAdd()>) have a last argument that will
  104. allow more detailed information on which key/value pair was not properly
  105. specified.
  106. =head2 Using References
  107. References to hashes and arrays are used throughout this package to pass
  108. information into and out of functions.
  109. =over 8
  110. =item Using Hash References
  111. Where a hash reference is required you can use anything that evaluates to a
  112. hash reference. e.g.
  113. $href = \%someHash;
  114. UserAdd(server, 2, $hRef);
  115. Or more directly:
  116. UserAdd(server, 2, \%someHash);
  117. =item Using Array references
  118. Array references are used in a similar manner to hash references. e.g.
  119. $aref = \@someArray;
  120. UserEnum(server, $aref);
  121. Or more directly:
  122. UserEnum(server, \@someArray);
  123. =back
  124. Please note: Any C<*Get*()> or C<*Enum()> operation will first clear the
  125. contents of the input hash or array being referenced.
  126. See L<EXAMPLES> and the test.pl script for examples of usage.
  127. =head1 DATA STRUCTURES
  128. Most the the functions in the underlying API allow the programmer to pass
  129. specify at runtime the amount of information that is supplied to the
  130. function. For example, the C<NetUserGetInfo()> call allows the programmer to
  131. specify levels of 0, 1, 2, 3 (and others). Having specified this level, the
  132. function returns a structure that will contain different fields. For a
  133. level C<0>, the function returns a structure that has only one field. For a
  134. supplied level of 1, the function returns a structure with C<8> fields. The
  135. programmer needs to know in advance what fields should be provided or will
  136. be returned for a given level. This mechanism works very will since it
  137. effectively overloads functions without having to use different function
  138. prototypes. Perl provides better higher level data structures in the form
  139. of arrays and hashes. This package uses hashes as the means to pass these
  140. variable size structure into and out of functions.
  141. For any function that takes a reference to a hash as input, the programmer
  142. is expected to provide appropriate keys and corresponding values as well as
  143. the level parameter. The called function will then takes the values out of
  144. the supplied hash and build the approprite structure to pass to the
  145. underlying API function.
  146. For any function that takes a reference to a hash to recieve output, the
  147. function will first clear any keys an corresponding values in the supplied
  148. hash. It will call the underlying API call and will then return in the hash
  149. any keys and values that are applicable at the requested level.
  150. Example:
  151. The C<UserGetInfo()> can takes a number of levels. If called with level C<0>
  152. the supplied hash will, on return from the function, contain a single key
  153. and value - namely B<name>/B<requested-users-name>. If called with a level
  154. of C<1> the supplied hash will, on return from the function, contain 8 keys
  155. and values. The returned keys are C<name, password>, C<passwordAge>,
  156. C<priv>, C<homeDir>, C<comment>, C<flags>, C<scriptPath>. See
  157. L<USER INFO FIELDS> for more information on what these represent.
  158. =head1 Exports
  159. By default, Win32API::Net exports no symbols into the callers namespace.
  160. The following tags can be used to selectively import symbols into the
  161. main namespace.
  162. =over 8
  163. =item C<:User>
  164. Exports all symbols needed for the C<User*()> functions.
  165. See L<NET USER FUNCTIONS>.
  166. =item C<:Get>
  167. Exports all symbols needed for the C<Get*()> functions.
  168. See L<NET GET FUNCTIONS>.
  169. =item C<:Group>
  170. Exports all symbols needed for the C<Group*()> functions.
  171. See L<NET GROUP FUNCTIONS>.
  172. =item C<:LocalGroup>
  173. Exports all symbols needed for the C<LocalGroup*()> functions.
  174. See L<NET LOCAL GROUP FUNCTIONS>.
  175. =back
  176. =head1 NET USER FUNCTIONS
  177. The C<User*()> functions operate on NT user accounts.
  178. Administrator or Account Operator group membership is required to
  179. successfully execute most of these functions on a remote server or on a
  180. computer that has local security enabled. Administrator privileges are
  181. required to add an Administrator Privilege account. There are some
  182. exceptions to this whereby a user can change some of their own settings
  183. where these don't conflict with 'administrative information' (e.g. full
  184. name).
  185. The C<server> field can be the empty string, in which case the function
  186. defaults to running on the local computer. If you leave this field blank
  187. then you should ensure that you are running the function on a PDC or BDC
  188. for your current domain. Use the support function C<GetDCName()> to find out
  189. what the domain controller is, should you not be running this on the PDC.
  190. All functions in this section are 'DOMAIN functions'. This means that,
  191. for example, the C<UserGetLocalGroups()> function actually lists the
  192. domain's local groups of which the named user is a member.
  193. The following functions are available.
  194. =head2 UserAdd(server, level, hash, error)
  195. Add a new user account. The user name is taken from the C<name>-key's
  196. value in the supplied hash.
  197. =over 8
  198. =item C<server> - Scalar String
  199. The server on which to add the account.
  200. =item C<level> - Scalar Int
  201. Level of information provided in hash. This can be either 1, 2 or 3.
  202. See L<USER INFO LEVELS>.
  203. =item C<hash> - Hash Reference
  204. The information to use to add this account. This should have all the
  205. appropriate keys and values required for C<level>.
  206. =item C<error> - Scalar Int
  207. Provides information on which field in the hash was not properly specified.
  208. See L<USER FIELD ERRORS> for more information about what values this can
  209. take.
  210. =back
  211. =head2 UserChangePassword(server, user, old, new)
  212. Changes the password for C<user>. If the policy of the machine/domain
  213. only allows password changes if the C<user> is logged on then the C<user>
  214. must be logged on to execute this function. With Administrator or Account
  215. Operator privilege you can use this function to change anyone's password,
  216. so long as you know the old password.
  217. =over 8
  218. =item C<server> - Scalar String
  219. The C<server> on which to change the password.
  220. =item C<user> - Scalar String
  221. The name of the C<user> whose password is being changed.
  222. =item C<old> - Scalar String
  223. The existing password for C<user>.
  224. =item C<new> - Scalar String
  225. The new password for C<user>.
  226. =back
  227. =head2 UserDel(server, user)
  228. Deletes the specified C<user> account. Administrator or Account Operator
  229. privilege is required to execute this function.
  230. =over 8
  231. =item C<server> - Scalar String
  232. The C<server> on which to delete the C<user>.
  233. =item C<user> - Scalar String
  234. The C<user> account to delete.
  235. =back
  236. =head2 UserEnum(server, array[, filter])
  237. Enumerates all the accounts on server that satisfy C<filter>. Unlike the
  238. C<NetUserEnum()> function in the API, this function does not allow you
  239. to specify a level (internally it is hardcoded to 0). In Perl it is
  240. trivial to implement the equivalent function (should you need it) - see
  241. L<Example 1>.
  242. =over 8
  243. =item C<server> - Scalar String
  244. The C<server> on which to enumerate the accounts satisfying C<filter>.
  245. =item C<array> - Array Reference
  246. The array that will hold the names of all users on C<server> whose
  247. accounts match C<filter>.
  248. =item C<filter> - Scalar Int (optional)
  249. The filter to apply (see L<USER ENUM FILTER>). This argument is optional
  250. and if not present a default of C<FILTER_NORMAL_ACCOUNT> is used.
  251. =back
  252. =head2 UserGetGroups(server, user, array)
  253. Get the global groups for which C<user> is a member. It returns the group
  254. names in C<array>. Unlike the C<NetUserGetGroups()> function in the API,
  255. this function does not allow you to specify a level (internally is
  256. hardcoded to 0). In Perl it is trivial to implement the equivalent function
  257. (in the unlikely event that you might need it).
  258. =over 8
  259. =item C<server> - Scalar String
  260. The C<server> from which to get the groups of which C<user> is a member.
  261. =item C<user> - Scalar String
  262. The C<user> whose group membership you wish to examine.
  263. =item C<array> - Scalar String
  264. The array that will contain the group names to which C<user> belongs.
  265. =back
  266. =head2 UserGetInfo(server, user, level, hash)
  267. Returns the information at the specified C<level> for the named C<user>
  268. in C<hash>.
  269. =over 8
  270. =item C<server> - Scalar String
  271. The C<server> from which to get the requested information about C<user>.
  272. =item C<user> - Scalar String
  273. The C<user> whose information you want.
  274. =item C<level> - Scalar Int
  275. One of: 0, 1, 2, 3, 10, 11 and 20. See L<USER INFO LEVELS>.
  276. =item C<hash> - Hash Reference
  277. The hash that will contain the keys and values for the information
  278. requested. See L<USER INFO FIELDS> for information about which keys are
  279. present in a given level.
  280. =back
  281. =head2 UserGetLocalGroups(server, user, array[, flags])
  282. Gets the names of the local groups of which C<user> is a member. Unlike
  283. the C<NetUserEnum()> function in the API, this function does not allow you
  284. to specify a level. Since the underlying API restricts you to level 0 there
  285. really isn't any need to include it...
  286. =over 8
  287. =item C<server> - Scalar String
  288. The server from which to get the local groups of which C<user> is a member.
  289. =item C<user> - Scalar String
  290. The C<user> whose local group membership you wish to enumerate.
  291. =item C<array> - Array Reference
  292. The array that will hold the names of the local groups to which C<user>
  293. belongs.
  294. =item C<flags> - Scalar Int <em>(optional)</em>
  295. Either C<Win32API::Net::LG_INCLUDE_INDIRECT()> or 0. if C<flags> is
  296. omitted, the function internally uses 0. Specifying C<LG_INCLUDE_INDIRECT()>
  297. will include in the list the names of the groups of which the C<user> is
  298. indirectly a member (e.g. by being in a global group that is a member of a
  299. local group).
  300. This field can take no other values.
  301. =back
  302. =head2 UserModalsGet()
  303. This function is not currently implemented.
  304. =head2 UserModalsSet()
  305. This function is not currently implemented.
  306. =head2 UserSetGroups(server, user, array)
  307. Sets the (global) group membership for C<user> to the specified groups.
  308. Unlike the API function C<NetUserSetGroups()>, this function does not take a
  309. C<level> parameter (mainly because this option is largely redundant).
  310. =over 8
  311. =item C<server> - Scalar String
  312. The C<server> on which you wish to set the group membership for C<user>.
  313. =item C<user> - Scalar String
  314. The C<user> whose group membership you wish to set.
  315. =item C<array> - Array Reference
  316. The array containing the (global) group names to set the C<user>s
  317. membership of.
  318. =back
  319. This function will fail if any of the group names specified do not exist.
  320. =head2 UserSetInfo(server, user, level, hash, error)
  321. Sets the info for C<user> according to the information contained in C<hash>
  322. for C<level> (see L<USER INFO LEVELS>).
  323. =over 8
  324. =item C<server> - Scalar String
  325. The C<server> on which you wish to change the info for C<user>.
  326. =item C<user> - Scalar String
  327. The C<user> whose info you wish to change.
  328. =item C<level> - Scalar Int
  329. One of 0, 1, 2, 3, or 20 (according to Microsoft documentation). In
  330. practice, you can use all the 10xx levels as well to change most of the
  331. individual properties of the named C<user> - although this may not be
  332. supported in future...
  333. =item C<hash> - Hash Reference
  334. The hash that will contain the necessary key/value pairs required for
  335. C<level> (see L<USER INFO LEVELS>).
  336. =item C<error> - Scalar Int
  337. Provides information on which field in C<hash> were not properly
  338. specified. See L<USER FIELD ERRORS> for more information about what
  339. values can be returned in this field.
  340. =back
  341. =head1 NET GROUP FUNCTIONS
  342. The C<Group*()> functions all operate only on global groups. To modify
  343. local groups, use the corresponding C<LocalGroup*()> functions.
  344. Administrator or Account Operator group membership is required to
  345. successfully execute most of these functions on a remote server or on
  346. a computer that has local security enabled.
  347. The C<server> field can be the empty string, in which case the function
  348. defaults to running on the local computer. If you leave this field blank
  349. then you should ensure that you are running the function on a PDC or BDC
  350. for your current domain. Use the support function C<GetDCName()> to find out
  351. what the domain controller is, should you not be running this on the PDC.
  352. The following functions are available.
  353. =head2 GroupAdd(server, level, hash, error)
  354. Adds the specified group.
  355. =over 8
  356. =item C<server> - Scalar String
  357. The C<server> on which to add the group.
  358. =item C<level> - Scalar String
  359. The C<level> of information contained in C<hash>. This can be one of 0, 1
  360. or 2. See L<GROUP INFO LEVELS>.
  361. =item C<hash> - Hash Reference
  362. A hash containing the required key/value pairs for C<level>.
  363. =item C<error> - Scalar Int
  364. Provides information on which field in C<hash> was not properly specified.
  365. See L<GROUP FIELD ERRORS> for more information about what values can be
  366. returned in this field.
  367. =back
  368. =head2 GroupAddUser(server, group, user)
  369. Adds the specified C<user> to the specified C<group>.
  370. =over 8
  371. =item C<server> - Scalar String
  372. The C<server> on which to add the C<user> to C<group>.
  373. =item C<group> - Scalar String
  374. The C<group> to add the C<user> to.
  375. =item C<user> - Scalar String
  376. The C<user> to add to C<group>.
  377. =back
  378. =head2 GroupDel(server, group)
  379. Deletes the specified global group.
  380. =over 8
  381. =item C<server> - Scalar String
  382. The C<server> on which to delete the named C<group>.
  383. =item C<group> -Scalar String
  384. The C<group> to delete.
  385. =back
  386. =head2 GroupDelUser(server, group, user)
  387. Deletes the specified user from the specified group.
  388. =over 8
  389. =item C<server> - Scalar String
  390. The C<server> on which to delete C<user> from C<group>.
  391. =item C<group> - Scalar String
  392. The C<group> from which to delete C<user>.
  393. =item C<user> - Scalar String
  394. The C<user> to delete from C<group>.
  395. =back
  396. =head2 GroupEnum(server, array)
  397. Enumerates all the global groups on the server. Unlike the API call
  398. C<NetGroupEnum()>, this function does not allow you to specify a level
  399. (internally it is hardcoded to 0). In Perl it is trivial to implement
  400. the equivalent function (should you need it).
  401. =over 8
  402. =item C<server> - Scalar String
  403. The server on which to enumerate the (global) C<groups>.
  404. =item C<array> - Array Reference
  405. An array that, on return, will contain the C<group> names.
  406. =back
  407. =head2 GroupGetInfo(server, group, level, hash)
  408. Retrieves C<level> information for C<group> returning information in
  409. C<hash>.
  410. =over 8
  411. =item C<server> - Scalar String
  412. The C<server> from which to get the group information.
  413. =item C<group> - Scalar String
  414. The C<group> whose information you wish to obtain.
  415. =item C<level> - Scalar Int
  416. The C<level> of information you wish to retrieve. This can be one of 1, 2
  417. or 3. See L<GROUP INFO LEVELS>.
  418. =item C<hash> - Hash Reference
  419. The hash that will contain the information.
  420. =back
  421. =head2 GroupGetUsers(server, group, array)
  422. Returns (in C<array>) the users belonging to C<group>. Unlike the API
  423. call C<NetGroupGetUsers()>, this function does not allow you to specify
  424. a level (internally it is hardcoded to 0). In Perl it is trivial to
  425. implement the equivalent function (should you need it).
  426. =over 8
  427. =item C<server> - Scalar String
  428. The C<server> from which to get the group information.
  429. =item C<group> - Scalar String
  430. The C<group> whose users you wish to obtain.
  431. =item C<array> - Array Reference
  432. The array to hold the user names retrieved.
  433. =back
  434. =head2 GroupSetInfo(server, group, level, hash, error)
  435. Sets the information for C<group> according to C<level>.
  436. =over 8
  437. =item C<server> - Scalar String
  438. The C<server> on which to set the C<group> information.
  439. =item C<group> - Scalar String
  440. The C<group> whose information you wish to set.
  441. =item C<level> - Scalar Int
  442. The C<level> of information you are supplying in C<hash>. Level can be
  443. one of 0, 1 or 2. See L<GROUP INFO LEVELS>.
  444. =item C<hash> - Hash Reference
  445. The hash containing the required key/value pairs for C<level>.
  446. =item C<error> - Scalar String
  447. On failure, the C<error> parameter will contain a value which specifies
  448. which field caused the error. See L<GROUP FIELD ERRORS>.
  449. =back
  450. =head2 GroupSetUsers(server, group, array)
  451. Sets the membership of C<group> to contain only those users specified
  452. in C<array>. This function will fail if any user names contained in the
  453. array are not valid users on C<server>. On successful completion
  454. C<group> will contain only the users specified in C<array>. Use the
  455. functions C<GroupAddUser()/GroupDelUser()> to add and delete individual
  456. users from a group.
  457. =over 8
  458. =item C<server> - Scalar String
  459. The C<server> on which to set the C<group> membership.
  460. =item C<group> - Scalar String
  461. The C<group> to set the membership of.
  462. =item C<array> - Array Reference
  463. The array containing the names of all users who will be members of C<group>.
  464. =back
  465. =head1 NET LOCAL GROUP FUNCTIONS
  466. The C<LocalGroup*()> functions operate on local groups. If these
  467. functions are run on a PDC then these functions operate on the domains
  468. local groups.
  469. Administrator or Account Operator group membership is required to
  470. successfully execute most of these functions on a remote server or on a
  471. computer that has local security enabled.
  472. The C<server> field can be the empty string, in which case the function
  473. defaults to running on the local computer. If you leave this field blank
  474. then you should ensure that you are running the function on a PDC or BDC
  475. for your current domain. Use the support function C<GetDCName()> to find
  476. out what the domain controller is, should you not be running this on the PDC.
  477. The following functions are available.
  478. =head2 LocalGroupAdd(server, level, hash, error)
  479. Adds the specified group. The name of the group is contained in the C<name>
  480. key of C<hash>.
  481. =over 8
  482. =item C<server> - Scalar String
  483. The C<server> on which to add the group.
  484. =item C<level> - Scalar String
  485. The C<level> of information contained in C<hash>. This can be one of 0 or 1.
  486. See L<LOCAL GROUP INFO LEVELS>.
  487. =item C<hash> - Hash Reference
  488. A hash containing the required key/value pairs for C<level>.
  489. =item C<error> - Scalar Int
  490. Provides information on which field in C<hash> wasn't properly specified.
  491. See L<LOCAL GROUP FIELD ERRORS> for more information about what values
  492. this can take.
  493. =back
  494. =head2 LocalGroupAddMember()
  495. This function is obselete in the underlying API and has therefore not
  496. been implemented. Use C<LocalGroupAddMembers> instead.
  497. =head2 LocalGroupAddMembers(server, group, array)
  498. Adds the specified users (members) to the local group. Unlike the API
  499. function C<NetLocalGroupAddMembers()>, this function does not allow you
  500. to specify a level (internally it is hardcoded to 3).
  501. This was done to simplify the implementation. To add a 'local' user, you
  502. need only specify the C<name>. You can also specify users using the
  503. C<DOMAIN\user> syntax.
  504. =over 8
  505. =item C<server> - Scalar String
  506. The C<server> on which to add the members to C<group>.
  507. =item C<group> - Scalar String
  508. The C<group> to add the members to.
  509. =item C<array> - Array Reference
  510. The array containing the members to add to C<group>.
  511. =back
  512. =head2 LocalGroupDel(server, group)
  513. Delete the specified local group.
  514. =over 8
  515. =item C<server> - Scalar String
  516. The C<server> on which to delete the named C<group>.
  517. =item C<group> -Scalar String
  518. The C<group> to delete.
  519. =back
  520. =head2 LocalGroupDelMember()
  521. This function is obselete in the underlying API and has therefore not
  522. been implemented. Use C<LocalGroupDelMembers()> instead.
  523. =head2 LocalGroupDelMembers(server, group, array)
  524. Delete the specified users (members) of the local group. Unlike the API
  525. function C<NetLocalGroupDelMembers()>, this function does not allow you
  526. to specify a level (internally it is hardcoded to 3). This was done to
  527. simplify the implementation. To delete a 'local' user, you need only
  528. specify the C<name>. You can also specify users using the C<DOMAIN\user>
  529. syntax.
  530. =over 8
  531. =item C<server> - Scalar String
  532. The C<server> on which to delete the members from C<group>.
  533. =item C<group> - Scalar String
  534. The C<group> to delete the members from.
  535. =item C<array> - Array Reference
  536. The array containing the members to delete from C<group>.
  537. =back
  538. =head2 LocalGroupEnum(server, array)
  539. Enumerates all the local groups on the server. Unlike the API call
  540. C<NetLocalGroupEnum()>, this function does not allow you to specify a
  541. level (internally it is hardcoded to 0). In Perl it is trivial to
  542. implement the equivalent function (should you need it).
  543. =over 8
  544. =item C<server> - Scalar String
  545. The server on which to enumerate the (local) C<groups>.
  546. =item C<array> - Array Reference
  547. The array to hold the C<group> names.
  548. =back
  549. =head2 LocalGroupGetInfo(server, group, level, hash)
  550. Retrieves C<level> information for C<group>.
  551. =over 8
  552. =item C<server> - Scalar String
  553. The C<server> from which to get the group information.
  554. =item C<group> - Scalar String
  555. The C<group> whose information you wish to obtain.
  556. =item C<level> - Scalar Int
  557. The C<level> of information you wish to retrieve. This can be 0 or 1.
  558. See L<LOCAL GROUP INFO LEVELS>.
  559. =item C<hash> - Hash Reference
  560. The hash that will contain the information.
  561. =back
  562. =head2 LocalGroupGetMembers(server, group, hash)
  563. Retrieves the users belonging to C<group>. Unlike the API call
  564. C<NetLocalGroupGetUsers()>, this function does not allow you to specify
  565. a level (internally it is hardcoded to 0). In Perl it is trivial to
  566. implement the equivalent function (should you need it).
  567. =over 8
  568. =item C<server> - Scalar String
  569. The C<server> from which to retrieve the group information.
  570. =item C<group> - Scalar String
  571. The C<group> whose users you wish to obtain.
  572. =item C<array> - Array Reference
  573. The array to hold the user names retrieved.
  574. =back
  575. =head2 LocalGroupSetInfo(server, level, hash, error)
  576. Sets the information for C<group> according to C<level>.
  577. =over 8
  578. =item C<server> - Scalar String
  579. The C<server> on which to set the C<group> information.
  580. =item C<group> - Scalar String
  581. The C<group> whose information you wish to set.
  582. =item C<level> - Scalar Int
  583. The C<level> of information you are supplying in C<hash>.
  584. Level can be one of 0 or 1. See L<LOCAL GROUP INFO LEVELS>.
  585. =item C<hash> - Hash Reference
  586. The hash containing the required key/value pairs for C<level>.
  587. =item C<error> - Scalar String
  588. On failure, the C<error> parameter will contain a value which specifies
  589. which field caused the error. See L<LOCAL GROUP FIELD ERRORS>.
  590. =back
  591. =head2 LocalGroupSetMembers()
  592. This function has not been implemented at present.
  593. =head1 NET GET FUNCTIONS
  594. =head2 GetDCName(server, domain, domain-controller)
  595. Gets the C<domain-controllder> name for C<server> and C<domain>.
  596. =over 8
  597. =item C<server> - Scalar String
  598. The C<server> whose domain controller you wish to locate.
  599. =item C<domain> - Scalar String
  600. The C<domain> that C<server> is a member of whose domain-controller
  601. you wish the locate.
  602. =item C<domain-controller> - Scalar String (output)
  603. The name of the C<domain-controller> for the requested C<domain>.
  604. =back
  605. Note: This module does not implement the C<NetGetAnyDCName()>API function
  606. as this is obsolete.
  607. =head1 USER INFO LEVELS
  608. Most of the C<User*()> functions take a C<level> parameter. This C<level>
  609. specifies how much detail the corresponding C<hash> should contain (or in
  610. the case of a C<UserGet*()> function, will contain after the call). The
  611. following C<level> descriptions provide information on what fields should
  612. be present for a given level. See L<USER INFO FIELDS> for a description of
  613. the fields.
  614. =over 8
  615. =item Level 0
  616. name
  617. =item Level 1
  618. name, password, passwordAge, priv, homeDir, comment, flags, scriptPath
  619. =item Level 2
  620. name, password, passwordAge, priv, homeDir, comment, flags, scriptPath,
  621. authFlags, fullName, usrComment, parms, workstations, lastLogon,
  622. lastLogoff, acctExpires, maxStorage, unitsPerWeek, logonHours, badPwCount,
  623. numLogons, logonServer, countryCode, codePage
  624. =item Level 3
  625. name, password, passwordAge, priv, homeDir, comment, flags, scriptPath,
  626. authFlags, fullName, usrComment, parms, workstations, lastLogon, lastLogoff,
  627. acctExpires, maxStorage, unitsPerWeek, logonHours, badPwCount, numLogons,
  628. logonServer, countryCode, codePage, userId, primaryGroupId, profile,
  629. homeDirDrive, passwordExpired
  630. =item Level 10
  631. name, comment, usrComment, fullName
  632. =item Level 11
  633. name, comment, usrComment, fullName, priv, authFlags, passwordAge, homeDir,
  634. parms, lastLogon, lastLogoff, badPwCount, numLogons, logonServer,
  635. countryCode, workstations, maxStorage, unitsPerWeek, logonHours, codePage
  636. =item Level 20
  637. name, fullName, comment, flags, userId
  638. =item Level 21
  639. B<Not available in this implementation>
  640. =item Level 22
  641. B<Not available in this implementation>
  642. =item Level 1003
  643. password
  644. =item Level 1005
  645. priv
  646. =item Level 1006
  647. homeDir
  648. =item Level 1007
  649. comment
  650. =item Level 1008
  651. flags
  652. =item Level 1009
  653. scriptPath
  654. =item Level 1010
  655. authFlags
  656. =item Level 1011
  657. fullName
  658. =item Level 1012
  659. usrComment
  660. =item Level 1013
  661. parms
  662. =item Level 1014
  663. workstations
  664. =item Level 1017
  665. acctExpires
  666. =item Level 1018
  667. maxStorage
  668. =item Level 1020
  669. unitsPerWeek, logonHours
  670. =item Level 1023
  671. logonServer
  672. =item Level 1024
  673. countryCode
  674. =item Level 1025
  675. codePage
  676. =item Level 1051
  677. primaryGroupId
  678. =item Level 1052
  679. profile
  680. =item Level 1053
  681. homeDirDrive
  682. =back
  683. =head1 USER INFO FIELDS
  684. The following is an alphabetical listing of each possible field, together
  685. with the data type that the field is expected to contain.
  686. =over 8
  687. =item C<acctExpires> - Scalar Int (UTC)
  688. The time (as the number of seconds since 00:00:00, 1st January 1970) when
  689. the account expires. A -1 in this field specifies that the account never
  690. expires.
  691. =item C<authFlags> - Scalar Int (See USER_AUTH_FLAGS).
  692. The level of authority that this use has. The value this can take depends
  693. on the users group membership - this value is therefore read only and
  694. cannot be set using C<UserAdd()> or C<UserSetInfo()>. Its value can be one
  695. of:
  696. =back
  697. User belongs to group Flag value
  698. --------------------- ----------
  699. Print Operators Win32API::Net::AF_OP_PRINT()
  700. Server Operators Win32API::Net::AF_OP_SERVER()
  701. Account Operators Win32API::Net::AF_OP_ACCOUNTS()
  702. =over 8
  703. =item C<badPwCount> - Scalar Int
  704. The number of times that the user has failed to logon by specifying an
  705. incorrect password.
  706. =item C<codePage> - Scalar Int
  707. The code page that this user uses.
  708. =item C<comment> - Scalar String
  709. The comment associated with this user account. This can be any string
  710. (apparently of any length).
  711. =item C<countryCode> - Scalar Int
  712. The country code that this user uses.
  713. =item C<flags> - Scalar Int (Bitwise OR of USER_FLAGS)
  714. The flags for this user. See L<USER FLAGS>.
  715. =item C<fullName> - Scalar String
  716. The users' full name.
  717. =item C<homeDir> - Scalar String
  718. The home directory of the user. This can be either a UNC path or an
  719. absolute path (drive letter + path). Can be the empty string ("").
  720. =item C<homeDirDrive> - Scalar String
  721. The home directory drive that the users home directory is mapped to
  722. (assuming that the specified home directory is a UNC path).
  723. =item C<lastLogon> - Scalar Int (UTC)
  724. The time (as the number of seconds since 00:00:00, 1st January 1970)
  725. that the user last logged on.
  726. =item C<lastLogoff> - Scalar Int (UTC)
  727. The time (as the number of seconds since 00:00:00, 1st January 1970)
  728. that the user last logged off .
  729. =item C<logonHours> - Reference to Array of Integers (length 21 elements)
  730. The times at which the user can logon. This should be an integer array
  731. with 21 elements. Each element represents an 8 hour period and each bit
  732. represents represents an hour. Only the lower byte of each integer is
  733. used. If this is left undefined then no restrictions are placed on the
  734. account.
  735. =item C<logonServer> - Scalar String
  736. The logon server for this user. Under Windows NT, this value cannot be
  737. set and will always have the value '\\*' when queried.
  738. =item C<maxStorage> - Scalar Int
  739. The current release of Windows NT does not implement disk quotas so
  740. it is believed that the value of this key is ignored.
  741. =item C<name> - Scalar String
  742. The user name that this request applies to. Most of the functions take
  743. the user name as a separate argument. In general, the user name provided
  744. should be the same as that in the one provided in the hash.
  745. =item C<numLogons> - Scalar Int
  746. The number of times that the named user has successfully logged on to
  747. this machine/domain.
  748. =item C<parms> - Scalar String
  749. The value of this key can be used by applications. There are none known
  750. to to author that use it, although it could be used to hold adminitrative
  751. information.
  752. =item C<password> - Scalar String
  753. The password to be set. The password is never returned in a C<UserGet()>
  754. operation.
  755. =item C<passwordAge> - Scalar Int (UTC)
  756. The current age of the password (stored as the number of seconds since
  757. 00:00:00, 1st January 1970).
  758. =item C<passwordExpired> - Scalar Int
  759. The value of this key is used in two different ways. When queried via
  760. C<UserGetInfo()> the return value is 0 is the password has not expired
  761. and 1 if it has. When setting the value via C<UserAdd()> or
  762. C<UserSetInfo()> a value of 0 indicates that the users' password has
  763. not expired whereas a value of 1 will force the user to change their
  764. password at the next logon.
  765. =item C<primaryGroupId> - Scalar Int
  766. The id of the primary group that this user belongs to. When creating
  767. accounts with C<UserAdd()> you should use a value of 0x201.
  768. =item C<priv> - Scalar Int (Bitwise OR of USER_PRIVILEGE_FLAGS)
  769. The privilege level that this user has. This is never returned from a
  770. C<UserGet()> call. See L<USER PRIVILEGE FLAGS>.
  771. =item C<profile> - Scalar String
  772. The profile that is associated with the named user. This can be UNC path,
  773. a local path or undefined.
  774. =item C<scriptPath> - Scalar String
  775. The path to the logon script for this user. This should be specified as a
  776. relative path and will cause the logon script to be run from (relative
  777. location) in the logon servers export directory.
  778. =item C<unitsPerWeek> - Scalar Int
  779. The value of this key represents the granularity of the logonHours array.
  780. Its use is beyond the scope of this package.
  781. =item C<usrComment> - Scalar String
  782. The user comment field (contrasted with the comment field ;-).
  783. =item C<workstations> - Scalar String
  784. A comma-separated string containing upto 8 workstation that the named
  785. user can login to. Setting a value for this key will then allow the
  786. named user to login to only those computers named.
  787. =item C<userId> - Scalar Int
  788. The user id associated with this user This value is generated by the
  789. system and cannot be set or changed using the C<UserAdd()> or
  790. C<UserSetInfo()> calls.
  791. =back
  792. =head1 USER FLAGS
  793. The following is an alphabetical listing of the user flags.
  794. The C<flags> key (see L<USER INFO FIELDS>) should be the bitwise OR of one
  795. or more of these values.
  796. =over 8
  797. =item C<UF_ACCOUNTDISABLE()>
  798. This account has been disabled.
  799. =item C<UF_DONT_EXPIRE_PASSWD()>
  800. Never expire the password on this account.
  801. =item C<UF_HOMEDIR_REQUIRED()>
  802. A home directory must be specified (ignored for NT).
  803. =item C<UF_INTERDOMAIN_TRUST_ACCOUNT()>
  804. The account represents a interdomain trust account.
  805. =item C<UF_LOCKOUT()>
  806. Lock out this account (or this account has been locked out due to
  807. security policy - i.e. badLogonCount is greater than your policy allows).
  808. This value can be cleared but not set by a C<UserSetInfo()> call.
  809. =item C<UF_NORMAL_ACCOUNT()>
  810. The account is a normal user account.
  811. =item C<UF_PASSWD_CANT_CHANGE()>
  812. The password for this account cannot be changed (execpt by an Administrator
  813. using one of the above calls).
  814. =item C<UF_PASSWD_NOTREQD()>
  815. A password is not required for this account.
  816. =item C<UF_SCRIPT()>
  817. This <strong>must be set when creating account on Windows NT.
  818. =item C<UF_SERVER_TRUST_ACCOUNT()>
  819. The account represents a Windows NT Backup Domain Controller account in
  820. the domain.
  821. =item C<UF_TEMP_DUPLICATE_ACCOUNT()>
  822. To quote the Microsoft Documentation <em>&quot;This is an account for
  823. users whose primary account is in another domain. This account provides
  824. user access to this domain, but not to any domain that trusts this domain.
  825. The User Manager refers to this account type as a local user account.
  826. =item C<UF_WORKSTATION_TRUST_ACCOUNT()>
  827. The account represents a computer account for a workstation or server in
  828. the domain.
  829. =back
  830. Please note that these are implemented as functions and are therefore
  831. called in the same way as other functions. You should typically use them
  832. like:
  833. $ufScript = Win32API::Net::UF_SCRIPT();
  834. =head1 USER PRIVILEGE FLAGS
  835. These following values are used in the C<priv> key. This field is never
  836. initialised on a C<UserGet*()> call and once set cannot be changed in a
  837. C<UserSetInfo()> call.
  838. =over 8
  839. =item C<USER_PRIV_ADMIN()>
  840. Account is an an administrative account.
  841. =item C<USER_PRIV_GUEST()>
  842. Account is a guest account.
  843. =item C<USER_PRIV_USER()>
  844. Account is a user account.
  845. =back
  846. Please note that these are implemented as functions and are therefore
  847. called in the same way as other functions. You should typically use them
  848. like:
  849. $userPrivUser = Win32API::Net::USER_PRIV_USER();
  850. =head1 USER ENUM FILTER
  851. These flags are used in the C<UserEnum()> function to specify which
  852. accounts to retrieve. It should be a bitwise OR of some (or all) of
  853. the following.
  854. =over 8
  855. =item C<FILTER_TEMP_DUPLICATE_ACCOUNT()>
  856. Show temporary duplicate account (one presumes).
  857. =item C<FILTER_NORMAL_ACCOUNT()>
  858. Show normal user account.
  859. =item C<FILTER_INTERDOMAIN_TRUST_ACCOUNT()>
  860. Show interdomain trust accounts.
  861. =item C<FILTER_WORKSTATION_TRUST_ACCOUNT()>
  862. Show workstation trust accounts.
  863. =item C<FILTER_SERVER_TRUST_ACCOUNT()>
  864. Show server trust accounts.
  865. =back
  866. Please note that these are implemented as functions and are therefore
  867. called in the same way as other functions. You should typically use them
  868. like:
  869. $filterNormalAccounts = Win32API::Net::FILTER_NORMAL_ACCOUNT();
  870. =head1 USER FIELD ERRORS
  871. For the C<User*()> functions that take an C<error> parameter this variable
  872. will, on failure, contain one of the following constants. Note that the
  873. function may fail because more than one key/value was missing from the
  874. input hash. You will only find out about the first one that was incorrectly
  875. specified. This is only really useful in debugging.
  876. =over 8
  877. =item C<USER_ACCT_EXPIRES_PARMNUM()>
  878. C<acctExpires> field was absent or not correctly specified.
  879. =item C<USER_AUTH_FLAGS_PARMNUM()>
  880. C<authFlags> field was absent or not correctly specified.
  881. =item C<USER_BAD_PW_COUNT_PARMNUM()>
  882. C<badPasswordCount> field was absent or not correctly specified.
  883. =item C<USER_CODE_PAGE_PARMNUM()>
  884. C<codePage> field was absent or not correctly specified.
  885. =item C<USER_COMMENT_PARMNUM()>
  886. C<comment> field was absent or not correctly specified.
  887. =item C<USER_COUNTRY_CODE_PARMNUM()>
  888. C<countryCode> field was absent or not correctly specified.
  889. =item C<USER_FLAGS_PARMNUM()>
  890. C<flags> field was absent or not correctly specified.
  891. =item C<USER_FULL_NAME_PARMNUM()>
  892. C<fullName> field was absent or not correctly specified.
  893. =item C<USER_HOME_DIR_DRIVE_PARMNUM()>
  894. C<homeDirDrive> field was absent or not correctly specified.
  895. =item C<USER_HOME_DIR_PARMNUM()>
  896. C<homeDir> field was absent or not correctly specified.
  897. =item C<USER_LAST_LOGOFF_PARMNUM()>
  898. C<lastLogoff> field was absent or not correctly specified.
  899. =item C<USER_LAST_LOGON_PARMNUM()>
  900. C<lastLogon> field was absent or not correctly specified.
  901. =item C<USER_LOGON_HOURS_PARMNUM()>
  902. C<logonHours> field was absent or not correctly specified.
  903. =item C<USER_LOGON_SERVER_PARMNUM()>
  904. C<logonServer> field was absent or not correctly specified.
  905. =item C<USER_MAX_STORAGE_PARMNUM()>
  906. C<maxStorage> field was absent or not correctly specified.
  907. =item C<USER_NAME_PARMNUM()>
  908. C<name> field was absent or not correctly specified.
  909. =item C<USER_NUM_LOGONS_PARMNUM()>
  910. C<numLogons> field was absent or not correctly specified.
  911. =item C<USER_PARMS_PARMNUM()>
  912. C<parms> field was absent or not correctly specified.
  913. =item C<USER_PASSWORD_AGE_PARMNUM()>
  914. C<passwordAge> field was absent or not correctly specified.
  915. =item C<USER_PASSWORD_PARMNUM()>
  916. C<password> field was absent or not correctly specified.
  917. =item C<USER_PRIMARY_GROUP_PARMNUM()>
  918. C<primaryGroup> field was absent or not correctly specified.
  919. =item C<USER_PRIV_PARMNUM()>
  920. C<priv> field was absent or not correctly specified.
  921. =item C<USER_PROFILE_PARMNUM()>
  922. C<profile> field was absent or not correctly specified.
  923. =item C<USER_SCRIPT_PATH_PARMNUM()>
  924. C<scriptPath> field was absent or not correctly specified.
  925. =item C<USER_UNITS_PER_WEEK_PARMNUM()>
  926. C<unitPerWeek> field was absent or not correctly specified.
  927. =item C<USER_USR_COMMENT_PARMNUM()>
  928. C<usrComment> field was absent or not correctly specified.
  929. =item C<USER_WORKSTATIONS_PARMNUM()>
  930. C<workstations> field was absent or not correctly specified.
  931. =back
  932. =head1 GROUP INFO LEVELS
  933. Some of the C<Group*()> functions take a C<level> parameter. This C<level>
  934. specifies how much detail the corresponding C<hash> should contain (or in
  935. the case of a C<GroupGetInfo()> function, will contain after the call).
  936. The following C<level> descriptions provide information on what fields
  937. should be present for a given level. See L<GROUP INFO FIELDS>
  938. for a description of the fields.
  939. =over 8
  940. =item C<Level 0>
  941. name.
  942. =item C<Level 1>
  943. name, comment.
  944. =item C<Level 2>
  945. name, comment, groupId, attributes.
  946. =item C<Level 1002>
  947. comment.
  948. =item C<Level 1005>
  949. attributes.
  950. =back
  951. =head1 GROUP INFO FIELDS
  952. =over 8
  953. =item C<attributes> - Scalar Int
  954. The attributes of the group. These are no longer settable in Windows NT 4.0
  955. and they are not currently supported in this package either.
  956. =item C<comment> - Scalar String
  957. The C<comment> that applies to this group. This is the only value that
  958. can be set via a GroupSetInfo call.
  959. =item C<groupId> - Scalar Int
  960. The groups Id.
  961. =item C<name> - Scalar String
  962. The groups name.
  963. =back
  964. =head1 GROUP FIELD ERRORS
  965. For the C<Group*()> functions that take an C<error> parameter
  966. this variable will, on failure, contain one of the following constants.
  967. Note that the function may fail because more than one key/value was
  968. missing from the input hash. You will only find out about the first one
  969. that was incorrectly specified. This is only really useful for debugging
  970. purposes.
  971. =over 8
  972. =item C<GROUP_ATTRIBUTES_PARMNUM()>
  973. C<attributes> field was absent or not correctly specified.
  974. =item C<GROUP_COMMENT_PARMNUM()>
  975. C<comment> field was absent or not correctly specified.
  976. =item C<GROUP_NAME_PARMNUM()>
  977. C<name> field was absent or not correctly specified.
  978. =back
  979. =head1 GROUP USERS INFO LEVELS
  980. The C<GroupGetUsers()> function can take a level of 0 or 1. These will
  981. return the following:
  982. =over 8
  983. =item C<Level 0>
  984. name.
  985. =item C<Level 1>
  986. name, attributes.
  987. =back
  988. =head1 GROUP USERS INFO FIELDS
  989. =over 8
  990. =item C<name> - Scalar String
  991. The user's name.
  992. =item C<attributes> - Scalar Int
  993. The attributes of the group. These are no longer settable in Windows NT
  994. 4.0 and they are not currently supported in this package either.
  995. =back
  996. =head1 LOCAL GROUP INFO LEVELS
  997. =over 8
  998. =item C<Level 0>
  999. name
  1000. =item C<Level 1>
  1001. name, comment
  1002. =item C<Level 1002>
  1003. comment
  1004. =back
  1005. =head1 LOCAL GROUP INFO FIELDS
  1006. =over 8
  1007. =item C<name> - Scalar String
  1008. The groups name
  1009. =item C<comment> - Scalar String
  1010. The groups 'comment'
  1011. =back
  1012. =head1 LOCAL GROUP FIELD ERRORS
  1013. For the C<LocalGroup*()> functions that take an C<error> parameter this
  1014. variable will, on failure, contain one of the following constants. Note
  1015. that the function may fail because more than one key/value was missing
  1016. or incorrectly specified in the input hash. You will only find out about
  1017. the first one that was incorrectly specified. This is only really useful
  1018. for debugging purposes.
  1019. =over 8
  1020. =item C<LOCALGROUP_NAME_PARMNUM()>
  1021. The C<name> field was absent or not correctly specified.
  1022. =item C<LOCALGROUP_COMMENT_PARMNUM()>
  1023. The C<comment> field wasabsent or not correctly specified.
  1024. =back
  1025. =head1 EXAMPLES
  1026. The following example shows how you can create a function in Perl that
  1027. has the same functionality as the C<NetUserEnum()> API call. The Perl
  1028. version doesn't have the level parameter so you must first use the
  1029. C<UserEnum()> function to retrieve all the account names and then iterate
  1030. through the returned array issuing C<UserGetInfo()> calls.
  1031. sub userEnumAtLevel {
  1032. my($server, $level, $filter) = @_;
  1033. my(@array);
  1034. Win32API::Net::UserEnum($server, \@array, $filter);
  1035. for $user (@array) {
  1036. Win32API::Net::UserGetInfo($server, $user, $level, \%hash);
  1037. print "This could access all level $level settings for $user - eg fullName $hash{fullName}\n";
  1038. }
  1039. }
  1040. userEnumAtLevel("", 2, 0);
  1041. =head1 AUTHOR
  1042. Bret Giddings, <[email protected]>
  1043. =head1 SEE ALSO
  1044. C<perl(1)>
  1045. =head1 ACKNOWEDGEMENTS
  1046. This work was built upon work done by HiP Communications along with
  1047. modifications to HiPs code by <[email protected]> and <[email protected]>.
  1048. In addition, I would like to thank Jenny Emby at GEC Marconi, U.K. for
  1049. proof reading this manual page and making many suggestions that have led
  1050. to its current layout. Last but not least I would like to thank Larry Wall
  1051. and all the other Perl contributors for making this truly wonderful
  1052. language.
  1053. =cut