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