source: LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix/User.pm @ 83

Last change on this file since 83 was 83, checked in by nanardon, 15 years ago
  • allow to sync specific object
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1package LATMOS::Accounts::Bases::Unix::User;
2
3use 5.010000;
4use strict;
5use warnings;
6
7use base qw(LATMOS::Accounts::Bases::Objects);
8
9our $VERSION = (q$Rev: 205 $ =~ /^Rev: (\d+) /)[0];
10
11=head1 NAME
12
13LATMOS::Ad - Perl extension for blah blah blah
14
15=head1 SYNOPSIS
16
17  use LATMOS::Accounts::Bases;
18  my $base = LATMOS::Accounts::Bases->new('unix');
19  ...
20
21=head1 DESCRIPTION
22
23Account base access over standard unix file format.
24
25=head1 FUNCTIONS
26
27=cut
28
29=head2 new(%options)
30
31Create a new LATMOS::Ad object for windows AD $domain.
32
33domain / server: either the Ad domain or directly the server
34
35ldap_args is an optionnal list of arguments to pass to L<Net::LDAP>.
36
37=cut
38
39sub new {
40    my ($class, $base, $id, @args) = @_;
41    # we profit of ref, quite easy
42    if (exists($base->{users}{$id}) && $base->{users}{$id}) {
43        if ($base->{users}{$id}{uid} < ($base->{min_uid} || 0)) {
44            return;
45        }
46        return bless($base->{users}{$id}, $class);
47    } else { return }
48}
49
50sub id {
51    $_[0]->{account}
52}
53
54sub get_field {
55    my ($self, $field) = @_;
56    for ($field) {
57        /^(sn|givenName)$/ and do {
58            my $gecos = $self->{gecos} || '';
59            my ($given, $sn) = $gecos =~ /^([^, ]+) +([^, ]+)/;
60            return $field eq 'sn' ? $sn : $given;
61        };
62    }
63    $self->{$field}
64}
65
66sub set_fields {
67    my ($self, %data) = @_;
68    foreach my $field (keys %data) {
69        # TODO check fields exists !
70        $field =~ /^(sn|givenName)$/ and next;
71        $self->{$field} = $data{$field};
72    }
73    1;
74}
75
761;
77
78__END__
79
80=head1 SEE ALSO
81
82=head1 AUTHOR
83
84Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
85
86=head1 COPYRIGHT AND LICENSE
87
88Copyright (C) 2008, 2009 CNRS SA/CETP/LATMOS
89
90This library is free software; you can redistribute it and/or modify
91it under the same terms as Perl itself, either Perl version 5.10.0 or,
92at your option, any later version of Perl 5 you may have available.
93
94
95=cut
Note: See TracBrowser for help on using the repository browser.