This is how I do it for multi-language computers.

use strict;
use Win32::Lanman;
use Win32::NetAdmin;

&CheckAdminPerms;

sub CheckAdminPerms
{
        my ($AdminGrp, @GrpList);
        my (@groups, $Error);
        my $user = "$ENV{'USERDOMAIN'}\\$ENV{'USERNAME'}";
        #$user = "domain\\account"; # Test account for Non-Admin
        Win32::NetAdmin::GetAliasFromRID("", 544, $AdminGrp);
        if(!Win32::Lanman::NetUserGetLocalGroups("", $user,
&LG_INCLUDE_INDIRECT, \@groups))
        {
                $^E = $Error = Win32::Lanman::GetLastError();
                &LogText($LogFile, "NetUserGetLocalGroups error: $Error
$^E");
                my $Message = "Administrator permissions for the account
\'$user\' could not be\n" .
                                                " verified. Since this is a
requirement, the program will exit after the OK\n" .
                                                " button is
pressed.\n\nGetAliasFromRID(\"\", 544)\n Error: $Error  $^E";
                my $Result = Win32::MsgBox($Message, MB_ICONSTOP, "LMS.pl");
                &LogText($LogFile, $Message);
                exit 1;
        }

        foreach my $group (@groups)
        {
        push (@GrpList, ${$group}{'name'});
        }
        if ("@GrpList" =~ /$AdminGrp/)
        {
                &LogText($LogFile, "$user found in local group: $AdminGrp");
        }
        else
        {
                my $Message = "The account \'$user\' does not have the
required Administrator permissions\n" .
                                                "on this computer to
properly execute this program. The program will exit after\n" .
                                                "the OK button is pressed.";
                my $Result = Win32::MsgBox($Message, MB_ICONSTOP, "LMS.pl");
                &LogText($LogFile, $Message);
                exit 1;
        }
}

-----Original Message-----
From: Eric Logeson [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 4:04 PM
To: [EMAIL PROTECTED]
Subject: adminmisc



I am using win32::adminmisc, and I thought there was a way to easily check
if a user is a member of the administrators group.

Am I confusing this with another module?

Thanks 
Eric
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to