Authen...::LDAP(3pm)
π Authen::Simple::LDAP π
okay bestie, listen up β this is a Perl man page (3pm, so it's a module doc, iykyk) from the User Contributed Perl Documentation collection. Her whole entire job? Simple LDAP authentication. That's it, that's the vibe. Let's get into it. π
β¨ NAME β¨
Authen::Simple::LDAP β literally just simple LDAP authentication, no cap. π¦
πΈ SYNOPSIS πΈ
Use it like a normal module:
use Authen::Simple::LDAP;
my $ldap = Authen::Simple::LDAP->new(
host => 'ldap.company.com',
basedn => 'ou=People,dc=company,dc=net'
);
if ( $ldap->authenticate( $username, $password ) ) {
# successfull authentication
}
# or as a mod_perl Authen handler
PerlModule Authen::Simple::Apache
PerlModule Authen::Simple::LDAP
PerlSetVar AuthenSimpleLDAP_host "ldap.company.com"
PerlSetVar AuthenSimpleLDAP_basedn "ou=People,dc=company,dc=net"
<Location /protected>
PerlAuthenHandler Authen::Simple::LDAP
AuthType Basic
AuthName "Protected Area"
Require valid-user
</Location>
two whole flavours, bestie β plain Perl object, or gluing yourself into Apache as a mod_perl Authen handler. pick your fighter. π
π¦ DESCRIPTION π¦
Authenticate against a LDAP service. That's the whole thing. That's the plot. π
π METHODS π
π new
This method takes a hash of parameters. The following options are valid:
hostβ the connection host, and honestly she's flexible: it can be a hostname, an IP number, or a URI. Defaults to"localhost". π
host => ldap.company.com
host => 10.0.0.1
host => ldap://ldap.company.com:389
host => ldaps://ldap.company.com
portβ the connection port, defaults to389. May be overridden byhostifhostis a URI. so like, don't fight over it, host wins. π
port => 389
timeoutβ connection timeout, defaults to60. β³
timeout => 60
versionβ the LDAP version to use, defaults to3. β¨
version => 3
binddnβ the distinguished name to bind to the server with. Defaults to bind anonymously. π«Ά
binddn => 'uid=proxy,cn=users,dc=company,dc=com'
bindpwβ the credentials to bind with. π
bindpw => 'secret'
basednβ the distinguished name of the search base. π³
basedn => 'cn=users,dc=company,dc=com'
filterβ the LDAP filter to use in search, defaults to"(uid=%s)". π
filter => '(uid=%s)'
scopeβ the search scope. Can be"base","one"or"sub", defaults to"sub". π―
filter => 'sub'
logβ any object that supports"debug","info","error"and"warn". π
log => Log::Log4perl->get_logger('Authen::Simple::LDAP')
π authenticate( $username, $password )
Returns true on success and false on failure. short king of a method, honestly. π
π EXAMPLE USAGE π
π Apple Open Directory
my $ldap = Authen::Simple::LDAP->new(
host => 'od.company.com',
basedn => 'cn=users,dc=company,dc=com',
filter => '(&(objectClass=inetOrgPerson)(objectClass=posixAccount)(uid=%s))'
);
πͺ Microsoft Active Directory
my $ldap = Authen::Simple::LDAP->new(
host => 'ad.company.com',
binddn => 'proxyuser@company.com',
bindpw => 'secret',
basedn => 'cn=users,dc=company,dc=com',
filter => '(&(objectClass=organizationalPerson)(objectClass=user)(sAMAccountName=%s))'
);
β οΈ Active Directory by default does not allow anonymous binds. It's recommended that a proxy user is used that has sufficient rights to search the desired tree and attributes. ngl bestie, don't skip this one. π«‘
π₯ SEE ALSO π₯
Authen::Simple::ActiveDirectory.Authen::Simple.Net::LDAP.
go read those too, they're the extended universe. π
π AUTHOR π
Christian Hansen "chansen@cpan.org" β the icon who wrote this. bow. π
π COPYRIGHT π
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. fr fr, free as in go wild. π¦
okay that's the whole page bestie!! this was perl v5.32.0, dated 2021-01-04, from Authen...::LDAP(3pm). stay authenticated, stay iconic, mwah π
πβ¨
π¦ where this page comes from
- debian bookworm: libauthen-simple-ldap-perl 0.3-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libauthen-simple-ldap-perl 0.3-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libauthen-simple-ldap-perl 0.3-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libauthen-simple-ldap-perl 0.3-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms