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

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