source: LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/User.pm @ 71

Last change on this file since 71 was 71, checked in by nanardon, 15 years ago
  • make objects path configurable
  • Property svn:keywords set to Id Rev
File size: 2.4 KB
Line 
1package LATMOS::Accounts::Bases::Ad::User;
2
3use 5.010000;
4use strict;
5use warnings;
6
7use base qw(LATMOS::Accounts::Bases::Ad::objects);
8use Net::LDAP;
9use Net::LDAP::Entry;
10use Net::LDAP::Control::Paged;
11use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED ); 
12use Net::LDAP::Util     qw( escape_filter_value );
13
14our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0];
15
16=head1 NAME
17
18LATMOS::Ad - Perl extension for blah blah blah
19
20=head1 SYNOPSIS
21
22  use LATMOS::Ad;
23  blah blah blah
24
25=head1 DESCRIPTION
26
27Stub documentation for LATMOS::Ad, created by h2xs. It looks like the
28author of the extension was negligent enough to leave the stub
29unedited.
30
31Blah blah blah.
32
33=head1 FUNCTIONS
34
35=cut
36
37sub _class_filter { '(&(ObjectClass=user) (!(ObjectClass=computer)))' }
38
39sub _key_attr { 'cn' } 
40
41sub _canonical_fields {
42    my ($self, $base, $mode) = @_;
43    (
44        qw(
45        sn name givenName
46        sAMAccountName uid gecos
47        homeDirectory loginShell
48        uidNumber gidNumber gecos
49        userPassword
50        shadowLastChange shadowMin shadowMax
51        shadowWarning shadowInactive shadowExpire
52        shadowFlag
53        description
54        mail
55        ),
56        ($mode !~ /w/
57            ? qw(cn dn)
58            : ()
59        )
60    )
61}
62
63sub _populate_entry {
64    my ($self, $entry, $field, $value) = @_;
65    for ($field) {
66    }
67    $entry->replace($field, $value);
68}
69
70
71sub _create {
72    my ($class, $base, $id, %data) = @_;
73
74    my $entry = Net::LDAP::Entry->new();
75
76    $entry->dn(join(',',
77        sprintf('cn=%s', escape_filter_value($id)),
78        $base->object_base_dn($class->type),
79    ));
80    $entry->replace('sAMAccountName', $id);
81    $entry->replace(objectClass => [ qw(top person organizationalPerson user)],);
82    $entry->replace(userAccountControl => 544);
83    $entry->replace(accountExpires => '9223372036854775807'); # TODO hardcoded, burk
84    $entry->replace(userPrincipalName => "$id\@" . $base->ad_domain);
85    foreach (keys %data) {
86        $class->_populate_entry($entry, $_, $data{$_});
87    }
88    my $msg = $base->ldap->add($entry);
89    return $msg->code ? 0 : 1;
90}
91
921;
93
94__END__
95
96=head1 SEE ALSO
97
98=head1 AUTHOR
99
100Olivier Thauvin, E<lt>olivier.thauvin@aerov.jussieu.frE<gt>
101
102=head1 COPYRIGHT AND LICENSE
103
104Copyright (C) 2008 CNRS SA/CETP/LATMOS
105
106This library is free software; you can redistribute it and/or modify
107it under the same terms as Perl itself, either Perl version 5.10.0 or,
108at your option, any later version of Perl 5 you may have available.
109
110
111=cut
Note: See TracBrowser for help on using the repository browser.