summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-09-29 23:53:14 +0200
committerArthur Schiwon <blizzz@owncloud.com>2013-10-17 19:13:14 +0200
commit8290929aa6fcb1e62e79d7acf8bf310c8d6f94d7 (patch)
tree5c688ce66b447650c661c97344fcd82f79ec0512 /apps/user_ldap/js
parent7c60384f20a1f5b9dea2288d8b39c5f556b4348f (diff)
downloadnextcloud-server-8290929aa6fcb1e62e79d7acf8bf310c8d6f94d7.tar.gz
nextcloud-server-8290929aa6fcb1e62e79d7acf8bf310c8d6f94d7.zip
LDAP Wizard: autodetect base DN
Diffstat (limited to 'apps/user_ldap/js')
-rw-r--r--apps/user_ldap/js/settings.js71
1 files changed, 57 insertions, 14 deletions
diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js
index 97470b4da41..45b1a9239f5 100644
--- a/apps/user_ldap/js/settings.js
+++ b/apps/user_ldap/js/settings.js
@@ -126,7 +126,7 @@ var LdapConfiguration = {
var LdapWizard = {
checkPortInfoShown: false,
- changeIndicators: {},
+ saveBlacklist: {},
ajax: function(param, fnOnSuccess, fnOnError) {
$.post(
@@ -144,10 +144,36 @@ var LdapWizard = {
applyChanges: function (result) {
for (id in result.changes) {
+ LdapWizard.saveBlacklist[id] = true;
$('#'+id).val(result.changes[id]);
}
},
+ checkBaseDN: function() {
+ host = $('#ldap_host').val();
+ user = $('#ldap_dn').val();
+ pass = $('#ldap_agent_password').val();
+
+ if(host && user && pass) {
+ param = 'action=guessBaseDN'+
+ '&ldap_serverconfig_chooser='+$('#ldap_serverconfig_chooser').val();
+
+ LdapWizard.ajax(param,
+ function(result) {
+ LdapWizard.applyChanges(result);
+ if($('#ldap_base').val()) {
+ $('#ldap_base').removeClass('hidden');
+ LdapWizard.hideInfoBox();
+ }
+ },
+ function (result) {
+ $('#ldap_base').removeClass('hidden');
+ LdapWizard.showInfoBox('Please specify a port');
+ }
+ );
+ }
+ },
+
checkPort: function() {
host = $('#ldap_host').val();
user = $('#ldap_dn').val();
@@ -162,30 +188,45 @@ var LdapWizard = {
LdapWizard.applyChanges(result);
if($('#ldap_port').val()) {
$('#ldap_port').removeClass('hidden');
- if(LdapWizard.checkPortInfoShown) {
- $('#ldapWizard1 .ldapWizardInfo').addClass('hidden');
- LdapWizard.checkPortInfoShown = false;
- }
+ LdapWizard.hideInfoBox();
}
},
function (result) {
$('#ldap_port').removeClass('hidden');
- $('#ldapWizard1 .ldapWizardInfo').text(t('user_ldap',
- 'Please specify a port'));
- $('#ldapWizard1 .ldapWizardInfo').removeClass('hidden');
- LdapWizard.checkPortInfoShown = true;
+ LdapWizard.showInfoBox('Please specify the BaseDN');
}
);
}
},
+ hideInfoBox: function() {
+ if(LdapWizard.checkInfoShown) {
+ $('#ldapWizard1 .ldapWizardInfo').addClass('hidden');
+ LdapWizard.checkInfoShown = false;
+ }
+ },
+
init: function() {
if($('#ldap_port').val()) {
$('#ldap_port').removeClass('hidden');
}
},
+ processChanges: function(triggerObj) {
+ if(triggerObj.id == 'ldap_host'
+ || triggerObj.id == 'ldap_port'
+ || triggerObj.id == 'ldap_dn'
+ || triggerObj.id == 'ldap_agent_password') {
+ LdapWizard.checkPort();
+ LdapWizard.checkBaseDN();
+ }
+ },
+
save: function(inputObj) {
+ if(LdapWizard.saveBlacklist.hasOwnProperty(inputObj.id)) {
+ delete LdapWizard.saveBlacklist[inputObj.id];
+ return;
+ }
param = 'cfgkey='+inputObj.id+
'&cfgval='+$(inputObj).val()+
'&action=save'+
@@ -196,16 +237,18 @@ var LdapWizard = {
param,
function(result) {
if(result.status == 'success') {
- if(inputObj.id == 'ldap_host'
- || inputObj.id == 'ldap_dn'
- || inputObj.id == 'ldap_agent_password') {
- LdapWizard.checkPort();
- }
+ LdapWizard.processChanges(inputObj);
} else {
// alert('Oooooooooooh :(');
}
}
);
+ },
+
+ showInfoBox: function(text) {
+ $('#ldapWizard1 .ldapWizardInfo').text(t('user_ldap', text));
+ $('#ldapWizard1 .ldapWizardInfo').removeClass('hidden');
+ LdapWizard.checkInfoShown = true;
}
};