Add external LDAP configuration

This commit is contained in:
Johannes Zellner
2019-08-29 09:59:57 +02:00
parent 6a08e08d7c
commit 8c44e558a8
4 changed files with 155 additions and 1 deletions

View File

@@ -413,6 +413,59 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
}
};
$scope.externalLdap = {
busy: false,
error: {},
success: false,
// fields
enabled: false,
url: '',
baseDn: '',
filter: '',
bindDn: '',
bindPassword: '',
submit: function () {
$scope.externalLdap.busy = true;
$scope.externalLdap.error = {};
$scope.externalLdap.success = false;
var config = {
enabled: $scope.externalLdap.enabled,
url: $scope.externalLdap.url,
baseDn: $scope.externalLdap.baseDn,
filter: $scope.externalLdap.filter
};
if ($scope.externalLdap.bindDn) {
config.bindDn = $scope.externalLdap.bindDn;
config.bindPassword = $scope.externalLdap.bindPassword;
}
Client.setExternalLdapConfig(config, function (error) {
$scope.externalLdap.busy = false;
if (error) {
console.error(error);
if (error.statusCode === 424) {
$scope.externalLdap.error.url = true;
} else if (error.statusCode === 400 && error.message === 'invalid baseDn') {
$scope.externalLdap.error.baseDn = true;
} else if (error.statusCode === 400 && error.message === 'invalid filter') {
$scope.externalLdap.error.filter = true;
} else if (error.statusCode === 400 && error.message === 'invalid bind credentials') {
$scope.externalLdap.error.credentials = true;
} else {
$scope.externalLdap.error.generic = error.message;
}
} else {
$scope.externalLdap.success = true;
}
});
}
};
$scope.copyToClipboard = function (/*value*/) {
document.execCommand('copy');
};
@@ -488,6 +541,19 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
});
}
function loadExternalLdapConfig() {
Client.getExternalLdapConfig(function (error, result) {
if (error) return console.error('Unable to get external ldap config.', error);
$scope.externalLdap.enabled = result.enabled;
$scope.externalLdap.url = result.url;
$scope.externalLdap.baseDn = result.baseDn;
$scope.externalLdap.filter = result.filter;
$scope.externalLdap.bindDn = result.bindDn;
$scope.externalLdap.bindPassword = result.bindPassword;
});
}
$scope.showNextPage = function () {
$scope.currentPage++;
refreshUsers();
@@ -505,6 +571,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
};
Client.onReady(refresh);
Client.onReady(loadExternalLdapConfig);
// setup all the dialog focus handling
['userAddModal', 'userRemoveModal', 'userEditModal', 'groupAddModal', 'groupEditModal', 'groupRemoveModal'].forEach(function (id) {