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.

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