stta/stta/home-tta/tools/ldap-lib.pl
2021-10-01 20:35:43 +01:00

46 lines
1.1 KiB
Perl
Executable File

# Library tools LDAP cache
# global variables
$conn = "";
$conncache = "";
use Mozilla::LDAP::Conn; # Main "OO" layer for LDAP
use Mozilla::LDAP::Utils; # LULU, utilities.
use strict;
no strict "vars";
sub connect
{
$conn = new Mozilla::LDAP::Conn ($config{ldap_server}, $config {ldap_port},
$config{ldap_user}, $config{ldap_passwd});
if (! $conn && $debug gt 0 ) {
print DebugLog "$text{'ldap_admerr'}\n";
print DebugLog "$text{'ldap_connerr'}\n";
}
}
sub connect_cache
{
$conncache = new Mozilla::LDAP::Conn ($config{ldapcache_server},
$config {ldapcache_port},$config{ldapcache_user}, $config{ldapcache_passwd});
if (! $conncache && $debug gt 0 ) {
print DebugLog "$text{'ldapcache_admerr'}\n";
print DebugLog "$text{'ldapcache_connerr'}\n";
}
}
sub sel_cache_obj
{
my ($dn) = @_;
my ($entry);
$entry = $conncache->browse ($dn);
if ($err = $conncache->getErrorCode ()) {
if ( $debug gt 0 ) {
print DebugLog "brw ($dn): $err:".$conncache->getErrorString ()."\n";
}
}
return $entry;
}