File Coverage

blib/lib/DBD/Sys/Plugin/Win32/Users.pm
Criterion Covered Total %
statement 13 21 61.9
branch 0 2 0.0
condition n/a
subroutine 5 7 71.4
pod 3 3 100.0
total 21 33 63.6


line stmt bran cond sub pod time code
1             package DBD::Sys::Plugin::Win32::Users;
2              
3 3     3   3020 use strict;
  3         8  
  3         109  
4 3     3   16 use warnings;
  3         6  
  3         109  
5              
6 3     3   16 use vars qw($VERSION @colNames);
  3         7  
  3         163  
7              
8 3     3   16 use base qw(DBD::Sys::Table);
  3         7  
  3         1010  
9             my $haveWin32pwent = 0;
10             eval {
11             require Win32::pwent;
12             $haveWin32pwent = 1;
13             };
14              
15             $VERSION = "0.102";
16             @colNames = qw(username passwd uid gid quota comment gcos dir shell expire);
17              
18             =pod
19              
20             =head1 NAME
21              
22             DBD::Sys::Plugin::Win32::Users - provides a table containing the operating system users
23              
24             =head1 SYNOPSIS
25              
26             $users = $dbh->selectall_hashref("select * from pwent", "username");
27              
28             =head1 DESCRIPTION
29              
30             This module provides the table I filled the data from the user
31             information got from L. Currently this contains only the
32             users known by the Windows LAN Manager, but hopefully it will be extended
33             to cover Active Directory users, soon.
34              
35             =head2 COLUMNS
36              
37             =head3 username
38              
39             Name of the user in this row how he/she authenticates himself/herself to
40             the system.
41              
42             =head3 passwd
43              
44             Encrypted password of the user - usually empty for current LANMAN functions.
45              
46             =head3 uid
47              
48             Numerical user id
49              
50             =head3 gid
51              
52             Numerical group id of the users primary group
53              
54             =head3 quota
55              
56             Quota, when supported by this system and set
57              
58             =head3 comment
59              
60             Comment, when set
61              
62             =head3 gcos
63              
64             General information about the user
65              
66             =head3 dir
67              
68             Users home directory
69              
70             =head3 shell
71              
72             Users default login shell
73              
74             =head3 expire
75              
76             Account expiration time, when available
77              
78             =head1 METHODS
79              
80             =head2 get_table_name
81              
82             Returns 'pwent'.
83              
84             =cut
85              
86 4     4 1 14 sub get_table_name() { return 'pwent'; }
87              
88             =head2 get_col_names
89              
90             Returns the column names of the table as named in L
91              
92             =cut
93              
94 0     0 1   sub get_col_names() { @colNames }
95              
96             =head2 collect_data
97              
98             Retrieves the data from the password database and put it into fetchable rows.
99              
100             =cut
101              
102             sub collect_data()
103             {
104 0     0 1   my @data;
105              
106 0 0         if ($haveWin32pwent)
107             {
108 0           Win32::pwent::endpwent(); # ensure we're starting fresh ...
109 0           while ( my ( $name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell, $expire ) =
110             Win32::pwent::getpwent() )
111             {
112 0           push( @data,
113             [ $name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell, $expire ] );
114             }
115 0           Win32::pwent::endpwent();
116             }
117              
118 0           return \@data;
119             }
120              
121             =head1 PREREQUISITES
122              
123             The module C is required to provide data for the
124             table.
125              
126             =head1 AUTHOR
127              
128             Jens Rehsack Alexander Breibach
129             CPAN ID: REHSACK
130             rehsack@cpan.org alexander.breibach@googlemail.com
131             http://www.rehsack.de/
132              
133             =head1 COPYRIGHT
134              
135             This program is free software; you can redistribute
136             it and/or modify it under the same terms as Perl itself.
137              
138             The full text of the license can be found in the
139             LICENSE file included with this module.
140              
141             =head1 SUPPORT
142              
143             Free support can be requested via regular CPAN bug-tracking system. There is
144             no guaranteed reaction time or solution time, but it's always tried to give
145             accept or reject a reported ticket within a week. It depends on business load.
146             That doesn't mean that ticket via rt aren't handles as soon as possible,
147             that means that soon depends on how much I have to do.
148              
149             Business and commercial support should be acquired from the authors via
150             preferred freelancer agencies.
151              
152             =cut
153              
154             1;
155