+==========================================================+
| |
| AdminMisc extension for Win32 Perl |
| ---------------------------------- |
| |
| by Dave Roth <
[email protected]> |
| |
| version v961016 |
| |
| |
| Copyright (c) 1996 Dave Roth. All rights reserved. |
| This program is free software; you can redistribute |
| it and/or modify it under the same terms as Perl itself. |
| |
+==========================================================+
Use under GNU General Public License or Larry Wall's "Artistic License"
-----------------------------------------------------------------------
This is a modification of the NetAdmin extension to Win32 Perl. This is used
ONLY on a Windows NT platform (most of these functions are not available on
the Windows 95 platform).
Please let me know if you hack the AdminMisc file and get it to successfully
work on Win95.
Added/altered functions to this version of NetAdmin:
UserCheckPassword($Domain, $User, $Password)
This will verify whether or not $Password is the correct password for
$User on the domain $Domain ($Domain could be a server instead).
If $Domain is Null ('') then the $User is assumed to be in the domain in which
the account is running.
If $User is Null ('') then the account to be changed is assumed to be the
account which the perl script is executing under.
account is running.
Returns: 0 if password is incorrect
1 if password is correct
UserChangePassword($Domain, $User, $OldPassword, $NewPassword)
This will change the password for the user $User in domain $Domain ($Domain
could be a server instead) from $OldPassword to $NewPassword.
If $Domain is Null ('') then the $User is assumed to be in the domain in which
the account is running.
If $User is Null ('') then the account to be changed is assumed to be the
account which the perl script is executing under.
Returns: 0 if password was NOT changed
1 if password was changed
GetLogonName()
This will return the name of the user this account is logged on as. This is
NOT necessarily the same as the account the perl script is running under.
An account can log on as another user (known as "impersonating" another
account).
Returns: Name that the current account is logged in as.
LogonAsUser($Domain, $User, $Password [, $LogonType)
This will log the current account on under a different account. The account
to log on under will be in the domain $Domain, user $User with the password
$Password.
If $Domain is Null ('') then the $User is assumed to be in the domain in which
the account is running.
$LogonType is by default (if not specified) LOGON32_LOGON_INTERACTIVE but
can be any valid logon type (eg. LOGON32_LOGON_BATCH).
Returns: 0 if unsuccessfull
1 if successfull
LogoffAsUser([1|0])
This will log the current account out from an "impersonated" account if
the current account is indeed impersonating another account.
If a non 0 parameter is passed then the the logoff is forced, that is,
you can force the impersonation to end even if LogonAsUser() was not called.
Returns: always returns 1
CreateProcessAsUser($CommandString [, $DefaultDirectory])
This creates a new process $CommandString starting in the $DefaultDirectory
(optional). The new process will be running under the account of the
currently impersonated user (LogonAsUser()).
There has been problems with this under NT 4.0 when the impersonated user
is not an Administrator.
Returns: -1 if failure otherwise the return is the OS createprocess result.
UserSetAttributes($Server, $UserName, $UserFullName, $Password, $PasswordAge,
$Privilege, $HomeDir, $Comment, $Flags, $ScriptPath)
This performs the same function as the original UserSetAttributes()
with the addition that it adds the ability to set the user's Full Name
($UserFullName).
Returns: 0 if unsuccessfull
1 if successfull
UserGetAttributes($Server, $UserName, $UserFullName, $Password, $PasswordAge,
$Privilege, $HomeDir, $Comment, $Flags, $ScriptPath)
This performs the same functino as the original UserGetAttributes()
with the addition that it adds the ability to get the user's Full Name
($UserFullName).
Returns: 0 if unsuccessfull
1 if successfull
GetHostAddress($DNS_Name)
gethostbyname($DNS_Name)
GetHostName($IP_Address)
gethostbyaddr($IP_Address)
These four functions are the same but go by different names for the sake
of sanity. You can freely mix and match any of these.
Providing either an IP address or a DNS name it will return the opposite
of what you provided or return a 0 if it fails.
Returns: IP address, DNS name if successful.
0 if failure.
DNSCache([1|0])
Sets the local DNS cache on (1) or off (0). If nothing is specified it
only returns the current state of the DNS cache.
Returns: 1 local DNS cache is active.
0 local DNS cache is not active.
DNSCacheSize([$Size])
Sets the local DNS cache size to $Size elements (or name/ip associations).
If nothing is specified then it only returns the current size of the cache.
NOTE: If a number is specified then the cache will be reset and every
thing in it will be lost.
NOTE: The size could be anything. Don't make it too large for memory and
speed sake.
The default size is 600.
Returns: Current size of the DNS cache.
DNSCacheCount()
Returns the current number of cached elements. This can not exceed the
value of DNSCacheSize.
Returns: Current number of cached elements.