1Catalyst::Model::LDAP::UEsnetrryC(o3n)tributed Perl DocuCmaetnatlaytsito:n:Model::LDAP::Entry(3)
2
3
4
6 Catalyst::Model::LDAP::Entry - Convenience methods for Net::LDAP::Entry
7
9 # In your controller
10 my $mesg = $c->model('Person')->search('(cn=Lou Rhodes)');
11 my $entry = $mesg->shift_entry;
12 print $entry->title;
13
15 This module simplifies use of Net::LDAP::Entry objects in your applica‐
16 tion. It makes accessors and mutators for all attributes on an entry.
17 For example:
18
19 print $entry->cn;
20
21 It also stores a reference to the parent LDAP connection, simplifying
22 updates to the entry:
23
24 $entry->title('Folk singer');
25 $entry->update;
26
28 If you want to provide your own methods on an LDAP entry, you can use
29 the "entry_class" configuration variable. For example:
30
31 # In lib/MyApp/Model/LDAP.pm
32 package MyApp::Model::LDAP;
33 use base qw/Catalyst::Model::LDAP/;
34
35 __PACKAGE__->config(
36 # ...
37 entry_class => 'MyApp::LDAP::Entry',
38 );
39
40 1;
41
42 # In lib/MyApp/LDAP/Entry.pm
43 package MyApp::LDAP::Entry;
44 use base qw/Catalyst::Model::LDAP::Entry/;
45 use DateTime::Format::Strptime;
46
47 sub get_date {
48 my ($self, $attribute) = @_;
49
50 my ($datetime) = ($self->get_value($attribute) =~ /^(\d{14})/);
51
52 my $parser = DateTime::Format::Strptime->new(
53 pattern => '%Y%m%d%H%M%S',
54 locale => 'en_US',
55 time_zone => 'UTC'
56 );
57
58 return $parser->parse_datetime($datetime);
59 }
60
61 1;
62
64 new
65
66 Override the Net::LDAP::Entry object constructor to take an optional
67 LDAP handle. If provided this will be used automatically on "update".
68
69 update
70
71 Override "update" to default to the optional LDAP handle provided to
72 the constructor.
73
74 can
75
76 Override "can" to declare existence of the LDAP entry attribute methods
77 from "AUTOLOAD".
78
80 * Catalyst::Model::LDAP
81 * Catalyst::Model::LDAP::Search
82
84 * Marcus Ramberg
85
87 This library is free software; you can redistribute it and/or modify it
88 under the same terms as Perl itself.
89
90
91
92perl v5.8.8 2008-02-19 Catalyst::Model::LDAP::Entry(3)