App-LDAP
view release on metacpan or search on metacpan
0.1.2 Wed Oct 2 15:13:46 CST 2013
- correct behavior of Command::Help
0.1.1 Fri Jan 11 15:03:39 CST 2013
- use Namespace::Dispatch 0.05
0.1.0 Fri Sep 21 18:00:48 2012
- App::LDAP::Role as the base of Roles
- refactor functions every commands used into App::LDAP::Role::Command
- separate App::LDAP::Utils into different Roles
- Role::Bindable for the command need to bind itself
- Role::Stem for the command has subcommands
- Role::FromEntry to make LDIF::* can new from a Net::LDAP::Entry
- tranlate schemas into ObjectClass::*
- reform LDIF::* via extending them from ObjectClass::*
- make sure LDIF::* satisfy the schema in tests
- change constructors of LDIF::* not to transform args in BUILDARG() except dn
- fix shadowLastChange to get correct day
- App::LDAP::Secret to load the secret file automatically
- LDIF#search for LDIF::*
- Command::Del::* use LDIF#search
lib/App/LDAP/Command/Init.pm view on Meta::CPAN
our $schemas = {};
sub run {
my ($self, ) = @_;
my $ldap = Net::LDAP->new("ldapi://");
my $sasl = Authen::SASL->new(mechanism => "EXTERNAL")
->client_new("ldap", "localhost");
$ldap->bind(undef, sasl => $sasl);
for my $schema (keys %{$schemas}) {
my $file = IO::String->new($schemas->{$schema});
my $entry = Net::LDAP::LDIF->new($file, "r", onerror => "die")->read_entry();
my $msg = $ldap->add($entry);
die $msg->error if $msg->code;
}
ldap()->add($self->create_gidnext);
ldap()->add($self->create_uidnext);
lib/App/LDAP/Connection.pm view on Meta::CPAN
=head1 SYNOPSIS
App::LDAP::Connection->new(
"ldap://localhost",
port => 389,
version => 3,
onerror => "die",
);
App::LDAP::Connection->instance->bind(
"cn=admin,dc=example,dc=org",
password => "password",
);
App::LDAP::Connection->instance->search(
base => "ou=People,dc=example,dc=org",
scope => "sub",
filter => "uid=foo",
);
lib/App/LDAP/Role/Bindable.pm view on Meta::CPAN
use Moose::Role;
use Term::ReadPassword;
with 'App::LDAP::Role';
around prepare => sub {
my $orig = shift;
my $self = shift;
($< == 0) ? bindroot() : binduser();
$self->$orig(@_);
};
sub bindroot {
ldap()->bind(
config()->{rootbinddn},
password => secret() // read_password("ldap admin password: "),
);
}
sub binduser {
ldap()->bind(
find_user("uidNumber", $<)->dn,
password => secret() // read_password("your password: "),
);
}
no Moose::Role;
1;
=pod
=head1 NAME
App::LDAP::Role::Bindable - make a command itself bindable to a LDAP server
=head1 SYNOPSIS
package App::LDAP::Command::YourCommand;
use Moose;
with qw( App::LDAP::Role::Command
App::LDAP::Role::Bindable );
package main;
App::LDAP::Command::YourCommand->new_with_options()->prepare()->run();
=head1 DESCRIPTION
This role hook the prepare() method to bind the handler through $UID to the LDAP server before running.
=cut
lib/App/LDAP/Secret.pm view on Meta::CPAN
1;
=pod
=head1 NAME
App::LDAP::Secret - loader of secret file
=head1 DESCRIPTION
this module would be called automatically in App::LDAP::run() to load the password for binding
=cut
t/data/ldap.conf view on Meta::CPAN
#timelimit 15
#deref never
base dc=example,dc=com
uri ldap://localhost
port 389
ldap_version 3
scope sub
timelimit 30
rootbinddn cn=admin,dc=example,dc=com
pam_login_attribute uid
pam_filter posixAccount
pam_password crypt
nss_base_passwd ou=People,dc=example,dc=com?one
nss_base_shadow ou=People,dc=example,dc=com?one
nss_base_group ou=Group,dc=example,dc=com?one
nss_base_hosts ou=Hosts,dc=example,dc=com?one
( run in 0.749 second using v1.01-cache-2.11-cpan-2398b32b56e )