A
AgnosticPope
I need to check and see if the current user has admin rights on a
system (different from rights on the domain. It's possible for a user
to be a local admin with no admin rights on the domain). I'm
attempting to write a function to do this, but I'm having trouble.
Here's what I have so far.
##################
sub IsAdmin {
use Win32::NetAdmin qw(UserGetAttributes);
$domain = Win32:
omainName();
$machine = Win32::NodeName;
$_ = Win32::LoginName; # grab the name of the current user
UserGetAttributes($machine, $_, $pwd, $passwordAge, $privilege,
$homeDir, $comment, $flags, $scriptPath)
or die "UserGetAttributes() failed: $^E";
return ($privilege==USER_PRIV_ADMIN);
}
#################
This obviously doesn't work. Changing $machine to $domain works, but
doesn't give me what I'm look for. Anyone out there help?
system (different from rights on the domain. It's possible for a user
to be a local admin with no admin rights on the domain). I'm
attempting to write a function to do this, but I'm having trouble.
Here's what I have so far.
##################
sub IsAdmin {
use Win32::NetAdmin qw(UserGetAttributes);
$domain = Win32:
$machine = Win32::NodeName;
$_ = Win32::LoginName; # grab the name of the current user
UserGetAttributes($machine, $_, $pwd, $passwordAge, $privilege,
$homeDir, $comment, $flags, $scriptPath)
or die "UserGetAttributes() failed: $^E";
return ($privilege==USER_PRIV_ADMIN);
}
#################
This obviously doesn't work. Changing $machine to $domain works, but
doesn't give me what I'm look for. Anyone out there help?