Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] Provide Win32::IsAdminUser() function

0 views
Skip to first unread message

Steve Hay

unread,
Dec 9, 2003, 10:02:16 AM12/9/03
to perl5-...@perl.org, perl-win3...@listserv.activestate.com
Hi,

Attached is a patch against maint-5.8 to add a new Win32 function into
the Perl core - Win32::IsAdminUser().

The function returns a boolean to indicate whether or not the user
running the perl.exe process has "Administrator" rights/privileges, i.e.
is a member of the local group of Administrators. This is only
meaningful on WinNT systems; on Win9x systems it always returns true.

This is a function that I've often found myself wanting, and seems to
fit in quite well with the kinds of thing already included in the core
on Win32.

Note that the patch makes use of some functions that are only available
on WinNT systems. To (hopefully) avoid breaking compilation on Win9x
systems, I have brought those functions in at run-time using a
LoadLibrary() call. There is already a precedent for that technique in
win32/win32.c (Win32::DomainName() uses it) so it should work OK, but I
haven't actually tested building it on Win9x myself.

Any comments from Win32 gurus, especially the guys at ActiveState, would
be very welcome.

Cheers,
- Steve


------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

patch.txt

Randy W. Sims

unread,
Dec 9, 2003, 2:03:57 PM12/9/03
to Steve Hay, perl5-...@perl.org, perl-win3...@listserv.activestate.com
On 12/9/2003 10:02 AM, Steve Hay wrote:

> Hi,
>
> Attached is a patch against maint-5.8 to add a new Win32 function into
> the Perl core - Win32::IsAdminUser().
>
> The function returns a boolean to indicate whether or not the user
> running the perl.exe process has "Administrator" rights/privileges, i.e.
> is a member of the local group of Administrators. This is only
> meaningful on WinNT systems; on Win9x systems it always returns true.
>
> This is a function that I've often found myself wanting, and seems to
> fit in quite well with the kinds of thing already included in the core
> on Win32.
>
> Note that the patch makes use of some functions that are only available
> on WinNT systems. To (hopefully) avoid breaking compilation on Win9x
> systems, I have brought those functions in at run-time using a
> LoadLibrary() call. There is already a precedent for that technique in
> win32/win32.c (Win32::DomainName() uses it) so it should work OK, but I
> haven't actually tested building it on Win9x myself.
>
> Any comments from Win32 gurus, especially the guys at ActiveState, would
> be very welcome.
>
> Cheers,
> - Steve
>

Is'nt this available throught POSIX::getuid() ? If not, it may be a
better place for this.

Regards,
Randy.

Michael G Schwern

unread,
Dec 9, 2003, 9:17:34 PM12/9/03
to Steve Hay, perl5-...@perl.org, perl-win3...@listserv.activestate.com
On Tue, Dec 09, 2003 at 03:02:16PM +0000, Steve Hay wrote:
> Attached is a patch against maint-5.8 to add a new Win32 function into
> the Perl core - Win32::IsAdminUser().

While useful, it doesn't seem to be of critical importance enough to
hard-code into perl. Why not put it in the libwin32 module? Then you can
have it without waiting for 5.8.3.


--
Michael G Schwern sch...@pobox.com http://www.pobox.com/~schwern/
I need a SHOWER a BURGER and some ROBOTS, STAT!
-- http://www.angryflower.com/allrigh.gif

Steve Hay

unread,
Dec 10, 2003, 4:22:14 AM12/10/03
to Michael G Schwern, perl5-...@perl.org, perl-win3...@listserv.activestate.com
Michael G Schwern wrote:

>On Tue, Dec 09, 2003 at 03:02:16PM +0000, Steve Hay wrote:
>
>
>>Attached is a patch against maint-5.8 to add a new Win32 function into
>>the Perl core - Win32::IsAdminUser().
>>
>>
>
>While useful, it doesn't seem to be of critical importance enough to
>hard-code into perl.
>

The same could be said for other Win32 functions in the core, but in
fact, rather than moving such stuff out of the core, there seem to be
moves afoot to merge the all the functions marked as [EXT] in
lib/Win32.pod into the core (they are currently provided by libwin32's
Win32.xs) -- see
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-01/msg00644.html

If the other [EXT] functions are coming into the core, then this one may
as well too.

>Why not put it in the libwin32 module? Then you can
>have it without waiting for 5.8.3.
>

If I put it in the libwin32 module then I'll have to wait for libwin32
0.20 ;) It seems to me that even Perl manages to be released more
frequently than libwin32 (especially now that the release schedule has
picked up to every 3 months or so).

Nick Ing-Simmons

unread,
Dec 10, 2003, 5:04:43 AM12/10/03
to Ran...@thepierianspring.org, Steve Hay, perl-win3...@listserv.activestate.com, perl5-...@perl.org
Randy W. Sims <Ran...@ThePierianSpring.org> writes:
>
>Is'nt this available throught POSIX::getuid() ? If not, it may be a
>better place for this.

Numeric uids and Win32 don't mix. One could perhaps return 0 for
the 'Administrator' but there may be several of those, it is a bit
(but not much) like having a root "group"...


0 new messages