Win32::pwent - pwent and grent support for Win32
use Win32; use Win32::pwent qw(getpwnam getpwent endpwent); my $uid = getpwnam(getlogin); my $win32login = Win32::LoginName(); while( my @pwent = getpwent ) { if( $pwent[0] eq $win32login and $pwent[2] == $uid ) { print( "It's me \\o/\n" ); endpwent(); last; } }
Win32::pwent should help building a bridge for Perl scripts running on Unix like systems to Win32.
It supports reading access to LanManager User-Info structures via the well known pwent and grent functions.
Win32::pwent doesn't export anything by default. Following function can be imported explicitely: endgrent, getpwent, getpwnam, getpwuid, entgrent, getgrent, getgrnam, getgrgid
endgrent
getpwent
getpwnam
getpwuid
entgrent
getgrent
getgrnam
getgrgid
All exported subroutines behaves as the same ones for Unix-like systems provided by Perl itself. See http://perldoc.perl.org/.
Returns the next entry from user list got from LANMAN user database. If this is the first call to getpwent (or the first call after an endpwent call), a user cache based on the LANMAN database using the functions GetUsers and UserGetInfo from the module Win32API::Net is created.
endpwent
GetUsers
UserGetInfo
see http://perldoc.perl.org/functions/getpwent.html
Free the user list cache and rewind the pointer for the next user entry.
see http://perldoc.perl.org/functions/endpwent.html
Rewind the pointer for the next user entry.
see http://perldoc.perl.org/functions/setpwent.html
Fetches the user (by name) entry from LANMAN user database and return it
see http://perldoc.perl.org/functions/getpwnam.html
fetches the user (by user id) entry from LANMAN user database and return it
see http://perldoc.perl.org/functions/getpwuid.html
Return the next group entry from LANMAN group database. If this is the first call to getgrent (or the first call after an endgrent call), a group cache based on the LANMAN database using the functions GroupEnum and GroupGetInfo from the module Win32API::Net is created.
GroupEnum
GroupGetInfo
see http://perldoc.perl.org/functions/getgrent.html
Free the group list cache and rewind the pointer for the next group entry.
Rewind the pointer for the next group entry.
Fetches the group (by name) entry from LANMAN user database and return it. This function doesn't uses the groups cache from getgrent.
see http://perldoc.perl.org/functions/getgrnam.html
Fetches the group (by group id) entry from LANMAN user database and return it. This function doesn't uses the groups cache from getgrent.
see http://perldoc.perl.org/functions/getgruid.html
Jens Rehsack, <rehsack at cpan.org>
<rehsack at cpan.org>
Win32::pwent uses the LAN manager interface, so it might be possible that users and groups from Active Directory are not recognized.
All functions provided by Win32::pwent are pure perl functions, so they don't provide the additional features the core functions provide, because the core implementation handles them as operators.
If you think you've found a bug then please also read "How to Report Bugs Effectively" by Simon Tatham: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
Please report any bugs or feature requests to bug-win32-pwent at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Win32-pwent. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-win32-pwent at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Win32::pwent
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Win32-pwent
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Win32-pwent
CPAN Ratings
http://cpanratings.perl.org/d/Win32-pwent
Search CPAN
http://search.cpan.org/dist/Win32-pwent/
Please recognize that the development of Open Source is done in free time of volunteers.
Jan Dubios from ActiveState who helped me through the required patches for Win32API::Net and give a lot feedback regarding compatibility.
Copyright (c) 2010 Jens Rehsack.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Win32::pwent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::pwent
CPAN shell
perl -MCPAN -e shell install Win32::pwent
For more information on module installation, please visit the detailed CPAN module installation guide.