Catalyst::Model::LDAP::Connection - Convenience methods for Net::LDAP
Subclass of Net::LDAP, which adds paging support and an additional method to rebless the entries. See Catalyst::Model::LDAP::Entry for more information.
If you want to override methods provided by Net::LDAP, you can use the connection_class configuration variable. For example:
connection_class
# In lib/MyApp/Model/LDAP.pm package MyApp::Model::LDAP; use base qw/Catalyst::Model::LDAP/; __PACKAGE__->config( # ... connection_class => 'MyApp::LDAP::Connection', ); 1; # In lib/MyApp/LDAP/Connection.pm package MyApp::LDAP::Connection; use base qw/Catalyst::Model::LDAP::Connection/; use Authen::SASL; sub bind { my ($self, @args) = @_; my $sasl = Authen::SASL->new(...); push @args, sasl => $sasl; $self->SUPER::bind(@args); } 1;
Create a new connection to the specific LDAP server.
my $conn = Catalyst::Model::LDAP::Connection->new( host => 'ldap.ufl.edu', base => 'ou=People,dc=ufl,dc=edu', );
Bind to the configured LDAP server using the specified credentials.
$conn->bind( dn => 'uid=dwc,ou=People,dc=ufl,dc=edu', password => 'secret', );
Search the configured directory using a given filter. For example:
my $mesg = $c->model('Person')->search('(cn=Lou Rhodes)'); my $entry = $mesg->shift_entry; print $entry->title;
This method overrides the search method in Net::LDAP to add paging support. The following additional options are supported:
search
page
Which page to return.
rows
Rows to return per page. Defaults to 25.
order_by
Sort the records (on the server) by the specified attribute. Required if you use page.
When paging is active, this method returns the server response and a Data::Page object. Otherwise, it returns the server response only.
Catalyst::Model::LDAP
Daniel Westermann-Clark
Marcus Ramberg (paging support)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Model::LDAP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Model::LDAP
CPAN shell
perl -MCPAN -e shell install Catalyst::Model::LDAP
For more information on module installation, please visit the detailed CPAN module installation guide.