LDAP/LDIF/User.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 44 / 44 CC 2 SCAR 1.8
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« LDAP/LDIF/Sudoer.pm ↑ Summary LDAP.pm »
1 package App::LDAP::LDIF::User;
2  
3 3 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 extends qw(
8 App::LDAP::ObjectClass::PosixAccount
9 App::LDAP::ObjectClass::ShadowAccount
10 App::LDAP::ObjectClass::InetOrgPerson
11 App::LDAP::LDIF
12 );
13  
14 2 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
15 2 my $orig = shift;
16 2 my $self = shift;
17 2 ▶ push @_, (dn => "uid=".{@_}->{uid}.",".{@_}->{base}) if grep /^base$/, @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep /^base$/u, @_ 1 1 2
18 2 $self->$orig(@_);
19 3 };
20  
21 has '+cn' => (
22 lazy => 1,
23 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
24 1 [shift->uid]
25 },
26 3 );
27  
28 has '+objectClass' => (
29 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
30 [
31 1 qw( inetOrgPerson
32 posixAccount
33 top
34 shadowAccount )
35 ],
36 },
37 3 );
38  
39 3 has '+userPassword' => (
40 required => 1,
41 );
42  
43 3 has '+loginShell' => (
44 default => "/bin/bash",
45 );
46  
47 has '+homeDirectory' => (
48 lazy => 1,
49 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
50 1 "/home/" . shift->uid;
51 },
52 3 );
53  
54 has '+shadowLastChange' => (
55 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
56 3 ▶ use Date::Calc qw(Today Delta_Days);
Subroutine BEGIN: called CC=1 SCAR=0.0
57 1 Delta_Days(
58 1970, 1, 1,
59 Today()
60 );
61 },
62 3 );
63  
64 3 has '+shadowMin' => (
65 default => 0,
66 );
67  
68 3 has '+shadowMax' => (
69 default => 99999,
70 );
71  
72 3 has '+shadowWarning' => (
73 default => 7,
74 );
75  
76 3 __PACKAGE__->meta->make_immutable;
77 3 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 3 1;
79  
80 =pod
81  
82 =head1 NAME
83  
84 App::LDAP::LDIF::User - the representation of users in LDAP
85  
86 =head1 SYNOPSIS
87  
88 my $user = App::LDAP::LDIF::User->new(
89 base => $base, # the OU (organization unit) which the user belongs to
90 uid => $name, # user name
91 userPassword => $password, # the password used by the user
92 uidNumber => $uid, # the uid of the user
93 gidNumber => $gid, # the gid of the user
94 sn => [$sn], # the surname of this user
95 );
96 # these 6 parameters are required
97 # extra parameters of attributes such as title of User can be provided in constructor, too.
98  
99 $user->loginShell("/bin/zsh")
100 # set zsh as the user's shell
101  
102 $uesr->gidNumber("27")
103 # set the user to have 27 as group id
104  
105 my $entry = $user->entry
106 # get the user as a instance of Net::LDAP::Entry
107  
108 my $from_entry = App::LDAP::LDIF::User->new($entry)
109 # new from a Net::LDAP::Entry instance
110  
111 =head1 DESCRIPTION
112  
113 App::LDAP::LDIF::User is composed of objectClass top, posixAccount, shadowAccount and inetOrgPerson.
114  
115 The objectClass top is described in RFC2256 (core.schema of OpenLDAP) indicating this kind of entry MUST have objectClass.
116  
117 The early versions used objectClass account rather than inetOrgPerson. Both account and inetOrgPerson are STRUCTURAL so
118 that only one of them could be satisfied.
119  
120 The objectClass posixAccount and shadowAccount are described in RFC2307 (nis.schema of OpenLDAP).
121  
122 The objectClass inetOrgPerson is described in RFC2798 (inetorgperson.schema of OpenLDAP). The inetOrgPerson is derived
123 from organizationalPerson which is derived from person.
124  
125 =head1 NOTES
126  
127 =head2 userPassword
128  
129 The objectClass posixAccount and shadowAccount define userPassword MAY be an attribute of a uesr. Because App::LDAP is
130 designed for working with pam_ldap, userPassword is defined as a required attribute here.
131  
132 =head2 sn
133  
134 The objectClass inetOrgPerson is derived from organizationalPerson which is derived from person. The person defines sn
135 MUST be a attribute of a user. Since the inetOrgPerson has sn as a required attribute.
136  
137 =head2 cn
138  
139 required attributes. default [ $self->uid ]
140  
141 =head2 loginShell
142  
143 default /bin/bash
144  
145 =head2 shadowLastChange
146  
147 the days from Unix Epoch that last time you changed password.
148  
149 default value is calculated via Date::Calc::Delta_Days().
150  
151 =head2 shadowMin
152  
153 the minimum days that user can change their password.
154  
155 default 0
156  
157 =head2 shadowMax
158  
159 the maximun days that user have to change their password.
160  
161 default 99999
162  
163 =head2 shadowWarning
164  
165 the day that user would be warned before password to be expired
166  
167 default 7
168  
169 =head2 homeDirectory
170  
171 default "/home/" . $self->uid
172  
173 =cut
« LDAP/LDIF/Sudoer.pm ↑ Summary LDAP.pm »