-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_adenabled.pl
More file actions
133 lines (97 loc) · 3.03 KB
/
db_adenabled.pl
File metadata and controls
133 lines (97 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/perl
#
use warnings;
use strict;
use LinWin::Schema;
## begin user documentation stuff
use Getopt::Long;
use Pod::Usage;
my $db_adenabled_VER = '0.1';
my $opt_debug = 0;
my ( $opt_help, $opt_man, $opt_versions );
my $engid;
GetOptions(
'debug=i' => \$opt_debug,
'help!' => \$opt_help,
'man!' => \$opt_man,
'versions!' => \$opt_versions,
) or pod2usage( -verbose => 1 ) && exit;
pod2usage( -verbose => 1 ) && exit if ( $opt_debug !~ /^[10]$/ );
pod2usage( -verbose => 1 ) && exit if defined $opt_help;
pod2usage( -verbose => 2 ) && exit if defined $opt_man;
print
"\nModules, Perl, OS, Program info:\n",
" DBIx::Class $DBIx::Class::VERSION\n",
" Pod::Usage $Pod::Usage::VERSION\n",
" Getopt::Long $Getopt::Long::VERSION\n",
" strict $strict::VERSION\n",
" Perl $]\n",
" OS $^O\n",
" db_adenabled.pl $db_adenabled_VER\n", " $0\n", "\n\n"
&& exit
if defined $opt_versions;
## end user documentation stuff
my $schema = LinWin::Schema->connect('dbi:SQLite:db/example.db');
$schema->storage->debug(1) if $opt_debug;
my $ad_enabled_rs = $schema->resultset('User')->ad_enabled();
while ( my $user = $ad_enabled_rs->next ) {
print $user->CRSID . " ";
print $user->ENGID . " ";
print $user->status->STATUS_NAME;
print "\n";
}
END {
if ( defined $opt_versions ) {
print
"\nModules, Perl, OS, Program info:\n",
" DBIx::Class $DBIx::Class::VERSION\n",
" Pod::Usage $Pod::Usage::VERSION\n",
" Getopt::Long $Getopt::Long::VERSION\n",
" strict $strict::VERSION\n",
" Perl $]\n",
" OS $^O\n",
" db_adenabled.pl $db_adenabled_VER\n",
" $0\n",
"\n\n";
}
}
=head1 NAME
db_adenabled.pl
=head1 SYNOPSIS
db_adenabled.pl ./tcbfile.csv
=head1 DESCRIPTION
Find all users which have active directory enabled and print them out. Can
be modified to limit the search to not all users.
Switches that don't define a value can be done in long or short form.
eg:
db_adenabled.pl --man
db_adenabled.pl -m
=head1 ARGUMENTS
File
--help print Options and Arguments instead of importing into db
--man print complete man page instead of importing into db
=head1 OPTIONS
--versions print Modules, Perl, OS, Program info
--debug 0 don't print debugging information (default)
--debug 1 print debugging information
=head1 AUTHOR
Gavin Rogers
=head1 CREDITS
=head1 TESTED
DBIx::Class 0.08250
Pod::Usage 1.36
Getopt::Long 2.41
strict 1.04
Perl 5.010001
OS linux
=head1 BUGS
None that I know of.
=head1 TODO
Add input (i.e. give the program a list of users?)
=head1 UPDATES
2013-08-21
Added user documentation
2013-08-19
Initial working code
=cut
## Please see file perltidy.ERR