source: LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix/Group.pm @ 72

Last change on this file since 72 was 72, checked in by nanardon, 15 years ago
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1package LATMOS::Accounts::Bases::Unix::Group;
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->{groups}{$id}) && $base->{groups}{$id}) {
43        if ($base->{groups}{$id}{gid} < ($base->{min_gid} || 0)) {
44            return;
45        }
46        return bless($base->{groups}{$id}, $class);
47    } else { return }
48}
49
50sub get_field {
51    my ($self, $field) = @_;
52    if ($field eq 'user_list') {
53        return [ keys %{ $self->{'users'} || {} } ];
54    }
55    $self->{$field}
56}
57
58sub set_fields {
59    my ($self, %data) = @_;
60    foreach my $field (keys %data) {
61        # TODO check fields exists !
62        if ($field eq 'user_list') {
63            $self->{'users'} = {};
64            foreach (ref $data{$field} ? (@{ $data{$field} || [] }) : ($data{$field})) {
65                $self->{'users'}{$_} = 1;
66            }
67        } else {
68            $self->{$field} = $data{$field};
69        }
70    }
71    1;
72}
73
741;
75
76__END__
77
78=head1 SEE ALSO
79
80=head1 AUTHOR
81
82Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
83
84=head1 COPYRIGHT AND LICENSE
85
86Copyright (C) 2008, 2009 CNRS SA/CETP/LATMOS
87
88This library is free software; you can redistribute it and/or modify
89it under the same terms as Perl itself, either Perl version 5.10.0 or,
90at your option, any later version of Perl 5 you may have available.
91
92
93=cut
Note: See TracBrowser for help on using the repository browser.