App-LDAP

 view release on metacpan or  search on metacpan

lib/App/LDAP/Command/Export.pm  view on Meta::CPAN

    is  => "rw",
    isa => "Str",
);

sub run {
    my ($self) = shift;

    my $file = $self->extra_argv->[1];

    if (! defined($file)) {
        say "you must give the file name to export";
        exit;
    }

    my @entries = ldap()->search(
        base   => $self->base   // config()->{base},
        scope  => $self->scope  // config()->{scope},
        filter => $self->filter // "objectClass=*",
    )->entries;


lib/App/LDAP/Command/Import.pm  view on Meta::CPAN


    shift @ARGV;
    process($_) for @ARGV;
}

sub process {
    my ($file) = @_;

    if (-f $file) {

        say "import $file...";

        my $ldif = Net::LDAP::LDIF->new($file, "r", onerror => 'die');

        while (!$ldif->eof) {
            my $entry = $ldif->read_entry;
            my $msg = ldap()->add($entry);
            warn $msg->error() if $msg->code;
        }

    } else {
        say "$_ don\'t exist. skip.";
        return;
    }

}

1;

=pod

=head1 NAME

lib/App/LDAP/Command/Passwd.pm  view on Meta::CPAN

            die "you may not view or modify password information for " . $user->dn;
        }
        $self->distinguish->($user);
    }
}

sub distinguish {
    my $self = shift;

    if ($self->lock && $self->unlock) {
        say "I'm dazzled with your key :p";
        exit;
    }

    if ($self->unlock) {
        return \&unlock_user if $> == 0;
        die "Permission denied";
    }

    if ($self->lock) {
        return \&lock_user if $> == 0;

lib/App/LDAP/Command/Search.pm  view on Meta::CPAN


    my $filter = $self->extra_argv->[1] or die "no filter specified";

    my @entries = ldap()->search(
        base => config()->{base},
        scope => "sub",
        filter => $filter,
    )->entries;

    for (@entries) {
        say $_->ldif;
    }
}

__PACKAGE__->meta->make_immutable;
no Moose;

1;

lib/App/LDAP/Command/Version.pm  view on Meta::CPAN

package App::LDAP::Command::Version;

use Modern::Perl;

use Moose;

with qw( App::LDAP::Role::Command );

sub run {
    say $App::LDAP::VERSION;
}

__PACKAGE__->meta->make_immutable;
no Moose;

1;

lib/App/LDAP/LDIF.pm  view on Meta::CPAN

        is  => "rw",
        isa => "Str",
    );

    package Controller;
    my $dog = App::LDAP::LDIF::Animal->new( name => "lucky" );

    my $dog->save;

    my $cat = App::LDAP::LDIF::Animal->find( name => "mou" );
    say $cat->entry->ldif;

=cut

lib/App/LDAP/Role/Stem.pm  view on Meta::CPAN

with qw( App::LDAP::Role );

around run => sub {
    my $orig = shift;
    my $self = shift;

    $self->$orig(@_);

    my $handler = $self->current_handler;

    say "usage: ldap$handler [subhandler]\n";

    say "Available subhandlers are:";

    my $leaves = ref($self)->leaves();

    for (@$leaves) {
        printf("   %-11s", $_);
        # show annotation of the module here;
        say "";
    }
};

sub current_handler {
    my ($self, ) = @_;

    my $command = lc(ref($self));

    $command =~ s{app::ldap::command}{};
    $command =~ s{::}{ }g;



( run in 3.648 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )