AddressBook
view release on metacpan or search on metacpan
examples/ldap-abook.conf view on Meta::CPAN
write_format="Tr(td([$fullname . ($description ? " ($description)" : ''),
table(Tr([map{($attributes{$_}) ? td([$_,$attributes{$_}]) : '' } ('Home','Work','Pager','Mobile') ]))]))"
intra_attr_sep="<br>"
/>
<LDAP
objectclass="abookPerson"
hostname="localhost"
base="o=abook"
dn_calculate="'cn='.$cn"
username="cn=Manager,o=abook"
password="secret"
key_fields = "cn"
/>
<PDB
phone_display = "($category eq 'personal') ? 'Home,Work,E-mail' : 'Work,Home,E-mail'"
key_fields = "Name,First name"
port="/dev/pilot"
/>
</databases>
</AddressBook_config>
lib/AddressBook/Config.pm view on Meta::CPAN
order CDATA #IMPLIED
calculate CDATA #IMPLIED
calc_order CDATA #IMPLIED>
<!ATTLIST LDAP key_fields CDATA #IMPLIED
hostname CDATA #IMPLIED
objectclass CDATA #IMPLIED
base CDATA #IMPLIED
dn_calculate CDATA #IMPLIED
username CDATA #IMPLIED
password CDATA #IMPLIED>
<!ATTLIST LDIF key_fields CDATA #IMPLIED
filename CDATA #IMPLIED
objectclass CDATA #IMPLIED
base CDATA #IMPLIED
dn_calculate CDATA #IMPLIED>
<!ATTLIST DBI key_fields CDATA #IMPLIED
table CDATA #IMPLIED
dsn CDATA #IMPLIED>
lib/AddressBook/Config.pm view on Meta::CPAN
calculate="$firstname . ' ' . $lastname">
<db type="LDAP" name="cn" />
<db type="HTML" name="Full Name" />
</field>
</fields>
<databases>
<LDAP objectclass="inetOrgPerson"
base="o=abook"
dn_calculate="'cn='.$cn"
username="cn=Manager,o=abook"
password="secret"
key_fields="cn"
/>
</databases>
</AddressBook_config>
This defines three attributes with cannonical names "firstname", "lastname", and
"fullname". These are accessed in the LDAP backend context as "givenname", "sn" and
"cn", and in the HTML backend context as "First Name", "Last Name" and "Full Name"
respectively.
lib/AddressBook/Config.pm view on Meta::CPAN
<db type="ldap_server_2" name="sn" />
</field>
</fields>
<databases>
<ldap_server_1 driver="LDAP"
hostname="server_1"
objectclass="inetOrgPerson"
base="o=abook"
dn_calculate="'cn='.$cn"
username="cn=Manager,o=abook"
password="secret"
key_fields="cn"
/>
<ldap_server_2 driver="LDAP"
hostname="server_2"
objectclass="inetOrgPerson"
base="o=abook"
dn_calculate="'cn='.$cn"
username="cn=Manager,o=abook"
password="secret"
key_fields="cn"
/>
</databases>
</AddressBook_config>
See the various backend man pages for information on the <database> configuration
attributes. See also the sample configuration files in the 'examples' directory.
=cut
lib/AddressBook/DB/LDAP.pm view on Meta::CPAN
package AddressBook::DB::LDAP;
=head1 NAME
AddressBook::DB::LDAP - Backend for AddressBook to use LDAP.
=head1 SYNOPSIS
use AddressBook;
$a = AddressBook->new(source => "LDAP:hostname/ou=People,dc=example,dc=com",
username => "user", password => "pass");
$a->add($entry) || die $a->code;
=head1 DESCRIPTION
The Net::LDAP library module is required in order to use this package.
AddressBook::DB::LDAP supports random access backend database methods.
Behavior can be modified using the following options:
lib/AddressBook/DB/LDAP.pm view on Meta::CPAN
The base for LDAP queries.
=item objectclass
The objectclass for AddressBook entries.
=item username
An LDAP dn to use for accessing the server.
=item password
=item dn_calculate
A perl expression which, when eval'd returns a valid LDAP "dn"
(omitting the "base" part of the dn). Other attributes may be referenced as "$<attr>".
For example, if LDAP entries have a dn like: "cn=John Doe,mail=jdoe@mail.com", then use
the following:
dn_calculate="'cn=' . $cn . ',mail=' . $mail"
lib/AddressBook/DB/LDAP.pm view on Meta::CPAN
$self->{$_} = $args{$_};
}
my ($hostname,$base,$mesg);
if ($self->{dsn}) {
($hostname,$base) = split "/", $self->{dsn};
}
$self->{hostname} = $hostname || $self->{hostname};
$self->{base} = $base || $self->{base};
$self->{ldap} = Net::LDAP->new($self->{hostname}, async => 1 || croak $@);
unless ($self->{anonymous}) {
$mesg = $self->{ldap}->bind($self->{username}, password => $self->{password});
} else {
$mesg = $self->{ldap}->bind;
}
if ($mesg->is_error) {
croak "could not bind to LDAP server: " . $mesg->error;
}
return $self;
}
sub search {
( run in 1.214 second using v1.01-cache-2.11-cpan-49f99fa48dc )