App-MultiLanguage
view release on metacpan or search on metacpan
lib/App/MultiLanguage/LDAP.pm view on Meta::CPAN
my $self = bless {}, $type;
if ($arg_ref->{host} =~ /(?:.+):(?:\d+)/) {
$self->{_ldap_server} = $arg_ref->{host};
}else{
$self->{_ldap_server} .= (defined $arg_ref->{port})? ":$arg_ref->{port}":':389';
}
$self->{_ldap_base} = $arg_ref->{base};
$self->{_ldap_user} = $arg_ref->{user} if (defined $arg_ref->{user});
$self->{_ldap_pass} = $arg_ref->{password} if (defined $arg_ref->{password});
eval { $self->_connect; };
return undef if($@);
$self;
}
sub parse {
my $self = shift;
lib/App/MultiLanguage/LDAP.pm view on Meta::CPAN
or croak "$!";
$self->{handler} = $ldap;
$self->_bind if (defined $self->{_ldap_user} && defined $self->{_ldap_pass} );
}
sub _bind {
my $self = shift;
my $result = $self->{handler}->bind($self->{_ldap_user},
password => $self->{_ldap_pass},
port => $self->{_ldap_port} );
croak "$!" if $result->code;
}
sub _search {
my $self = shift;
my $search_args = join ')(cn=', @{$self->{search_args}};
my @attrs = ("cn", "en", $self->{language});
my %search = ( base => $self->{_ldap_base},
lib/App/MultiLanguage/LDAP.pm view on Meta::CPAN
=head1 METHODS
Following is the overview of all the available methods accessible via App::MultiLanguage::LDAP object.
=head2 new( host => '127.0.0.1', base => 'ou=language,dc=example,dc=com' )
Returns a new object or undef on failure. Can accept up to five arguments which are,
host - may be a host name or an IP number. TCP port may be specified after the host name followed by a colon (such as localhost:10389). The default TCP port for LDAP is 389.
port - Port to connect to on the remote server. May be overridden by HOST, for example, 127.0.0.1:389
user - It is a DN used for authentication.
password - Bind LDAP server with the given password.
base - The DN that is the base object entry relative to which the search is to be performed.
There is no scope option can be specified, default one is 'one'.
$object = new App::MultiLanguage::LDAP(
host => '127.0.0.1',
port => '389',
user => 'cn=manager,dc=example,dc=com',
password => 'secret',
base => 'ou=language,dc=example,dc=com'
);
=head2 language()
Set the display language expected in application. There are twenty-six languages can be passed as this argument.
# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)
# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
( run in 0.843 second using v1.01-cache-2.11-cpan-49f99fa48dc )