home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / Win32 / AdminMisc.pm next >
Encoding:
Perl POD Document  |  1997-08-10  |  4.2 KB  |  197 lines

  1. package Win32::AdminMisc;
  2.  
  3. $VERSION = '0.03';
  4.  
  5. #
  6. #AdminMisc.pm
  7. #   Written by Hip.Com but hacked to death by Dave Roth <rothd@roth.net>
  8.  
  9. require Exporter;
  10. require DynaLoader;
  11.  
  12. die "The Win32::AdminMisc module works only on Windows NT" if(!Win32::IsWinNT() );
  13.  
  14. @ISA= qw( Exporter DynaLoader );
  15. # Items to export into callers namespace by default. Note: do not export
  16. # names by default without a very good reason. Use EXPORT_OK instead.
  17. # Do not simply export all your public functions/methods/constants.
  18. @EXPORT = qw(
  19.     FILTER_TEMP_DUPLICATE_ACCOUNT
  20.     FILTER_NORMAL_ACCOUNT
  21.     FILTER_INTERDOMAIN_TRUST_ACCOUNT
  22.     FILTER_WORKSTATION_TRUST_ACCOUNT
  23.     FILTER_SERVER_TRUST_ACCOUNT
  24.     UF_TEMP_DUPLICATE_ACCOUNT
  25.     UF_NORMAL_ACCOUNT
  26.     UF_INTERDOMAIN_TRUST_ACCOUNT
  27.     UF_WORKSTATION_TRUST_ACCOUNT
  28.     UF_SERVER_TRUST_ACCOUNT
  29.     UF_MACHINE_ACCOUNT_MASK
  30.     UF_ACCOUNT_TYPE_MASK
  31.     UF_DONT_EXPIRE_PASSWD
  32.     UF_SETTABLE_BITS
  33.     UF_SCRIPT
  34.     UF_ACCOUNTDISABLE
  35.     UF_HOMEDIR_REQUIRED
  36.     UF_LOCKOUT
  37.     UF_PASSWD_NOTREQD
  38.     UF_PASSWD_CANT_CHANGE
  39.     USE_FORCE
  40.     USE_LOTS_OF_FORCE
  41.     USE_NOFORCE
  42.     USER_PRIV_MASK
  43.     USER_PRIV_GUEST
  44.     USER_PRIV_USER
  45.     USER_PRIV_ADMIN
  46. );
  47.  
  48. =head1 NAME
  49.  
  50. Win32::AdminMisc - manage network groups and users in perl
  51.  
  52. =head1 SYNOPSIS
  53.  
  54.     use Win32::AdminMisc;
  55.  
  56. =head1 DESCRIPTION
  57.  
  58. This module offers control over the administration of groups and users over
  59. a network.
  60.  
  61. =head1 FUNCTIONS
  62.  
  63. =head2 NOTE:
  64.  
  65. All of the functions return FALSE (0) if they fail, unless otherwise noted.
  66. server is optional for all the calls below. (if not given the local machine
  67. is assumed.)
  68.  
  69. =over 10
  70.  
  71. =item UserGetAttributes(server, userName, password, passwordAge, privilege, homeDir, comment, flags, scriptPath)
  72.  
  73. Gets password, passwordAge, privilege, homeDir, comment, flags, and
  74. scriptPath for user.
  75.  
  76. =item UserSetAttributes(server, userName, password, passwordAge, privilege, homeDir, comment, flags, scriptPath)
  77.  
  78. Sets password, passwordAge, privilege, homeDir, comment, flags, and
  79. scriptPath for user.
  80.  
  81. =item UserChangePassword(domainname, username, oldpassword, newpassword)
  82.  
  83. Changes a users password. Can be run under any account.
  84.  
  85. =item UsersExist(server, userName)
  86.  
  87. Checks if a User exists.
  88.  
  89. =item GetUsers(server, filter, \@userArray)
  90.  
  91. Fills userArray with the all of the User names.
  92.  
  93. =item GroupCreate(server, group, comment)
  94.  
  95. Creates a group.
  96.  
  97. =item GroupDelete(server, group)
  98.  
  99. Deletes a group.
  100.  
  101. =item GroupGetAttributes(server, groupName, comment)
  102.  
  103. Gets the comment.
  104.  
  105. =item GroupSetAttributes(server, groupName, comment)
  106.  
  107. Sets the comment.
  108.  
  109. =item GroupAddUsers(server, groupName, users)
  110.  
  111. Adds a user to a group.
  112.  
  113. =item GroupDelUsers(server, groupName, users)
  114.  
  115. Deletes a users from a group.
  116.  
  117. =item GroupIsMember(server, groupName, user)
  118.  
  119. Returns TRUE if user is a member of groupName.
  120.  
  121. =item GroupGetMembers(server, groupName, \@userArray)
  122.  
  123. Fills userArray with the members of groupName.
  124.  
  125. =item LocalGroupCreate(server, group, comment)
  126.  
  127. Creates a local group.
  128.  
  129. =item LocalGroupDelete(server, group)
  130.  
  131. Deletes a local group.
  132.  
  133. =item LocalGroupGetAttributes(server, groupName, comment)
  134.  
  135. Gets the comment.
  136.  
  137. =item LocalGroupSetAttributes(server, groupName, comment)
  138.  
  139. Sets the comment.
  140.  
  141. =item LocalGroupIsMember(server, groupName, user)
  142.  
  143. Returns TRUE if user is a member of groupName.
  144.  
  145. =item LocalGroupGetMembers(server, groupName, \@userArray)
  146.  
  147. Fills userArray with the members of groupName.
  148.  
  149. =item LocalGroupAddUsers(server, groupName, users)
  150.  
  151. Adds a user to a group.
  152.  
  153. =item LocalGroupDelUsers(server, groupName, users)
  154.  
  155. Deletes a users from a group.
  156.  
  157. =back
  158.  
  159. =cut
  160.  
  161. sub AUTOLOAD {
  162.  
  163.     local($constname);
  164.     ($constname = $AUTOLOAD) =~ s/.*:://;
  165.     #reset $! to zero to reset any current errors.
  166.     $!=0;
  167.     $val = constant($constname, @_ ? $_[0] : 0);
  168.     if ($! != 0) {
  169.     if ($! =~ /Invalid/) {
  170.         $AutoLoader::AUTOLOAD = $AUTOLOAD;
  171.         goto &AutoLoader::AUTOLOAD;
  172.     }
  173.     else {
  174.         ($pack,$file,$line) = caller;
  175.         die "Your vendor has not defined Win32::AdminMisc macro $constname, used in $file at line $line.";
  176.     }
  177.     }
  178.     eval "sub $AUTOLOAD { $val }";
  179.     goto &$AUTOLOAD;
  180. }
  181.  
  182. bootstrap Win32::AdminMisc;
  183.  
  184. 1;
  185. __END__
  186.  
  187.     
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.