LDAP Bind credential file option for ldap-useradmin

This commit is contained in:
Andrew Yoder
2020-08-15 13:29:24 -04:00
parent 5867b4120e
commit f6f72d547e
3 changed files with 18 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ ldap_port=LDAP server port,3,From NSS config file or default
ldap_tls=LDAP server uses encryption?,1,1-Yes SSL,2-Yes TLS,0-No
login=Bind to LDAP server as,3,Bind name from NSS config file
pass=Credentials for bind name above,12
ldap_pass_file=Path to LDAP bind credentials file,3
user_base=Base for users,3,From NSS config file
group_base=Base for groups,3,From NSS config file
other_class=Other objectClasses to add to new users,0

View File

@@ -24,6 +24,7 @@ imap_econn=Failed to connect to IMAP server $1
imap_elogin=Failed to login to IMAP server $1 as $2 : $3
conn_eldap_host=No LDAP client configuration file was found on your system, so the LDAP server must be set on the Module Config page
conn_elogin=No LDAP client configuration file was found on your system, so the LDAP login must be set on the Module Config page
conn_efile_open=Could not open the LDAP bind credentials file:
uedit_cap=User capabilities
uedit_samba=Samba login?

View File

@@ -65,9 +65,24 @@ if (!$cfile || !-r $cfile) {
}
}
# If a bind credentials file is defined, read the password from the file
# Otherwise, read the password from the "pass" config option
my $ldapPassword;
if ( $config{'ldap_pass_file'} ){
if (open my $fh, "<", $config{'ldap_pass_file'} ){
local $/;
$ldapPassword = <$fh>;
close($fh);
} else {
&error($text{'conn_efile_open'} . " " . $config{'ldap_pass_file'});
}
} else {
$ldapPassword = $config{'pass'};
}
local $ldap = &ldap_client::generic_ldap_connect(
$config{'ldap_host'}, $config{'ldap_port'},
$config{'ldap_tls'}, $config{'login'}, $config{'pass'});
$config{'ldap_tls'}, $config{'login'}, $ldapPassword);
if (ref($ldap)) { return $ldap; }
elsif ($_[0]) { return $ldap; }
else { &error($ldap); }