Merge pull request #1284 from ayoder770/master

LDAP Bind Credentials File Option for ldap-useradmin Webmin Module
This commit is contained in:
Jamie Cameron
2020-08-15 13:10:16 -07:00
committed by GitHub
4 changed files with 20 additions and 3 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

@@ -14,8 +14,8 @@ if ($config{'auth_ldap'}) {
else {
if ($_[0]) {
return 1 if (!$config{'ldap_host'} || !$config{'login'} ||
!$config{'pass'} || !$config{'user_base'} ||
!$config{'group_base'});
( !$config{'pass'} && !$config{'ldap_pass_file'} ) ||
!$config{'user_base'} || !$config{'group_base'});
}
}
if ($_[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); }