);
},
+ testConfiguration: function(onSuccess, onError) {
+ $.post(
+ OC.filePath('user_ldap','ajax','testConfiguration.php'),
+ $('#ldap').serialize(),
+ function (result) {
+ if (result.status === 'success') {
+ onSuccess(result);
+ } else {
+ onError(result);
+ }
+ }
+ );
+ },
+
clearMappings: function(mappingSubject) {
$.post(
OC.filePath('user_ldap','ajax','clearMappings.php'),
user = $('#ldap_dn').val();
pass = $('#ldap_agent_password').val();
+ //FIXME: determine base dn with anonymous access
if(host && port && user && pass) {
param = 'action=guessBaseDN'+
'&ldap_serverconfig_chooser='+$('#ldap_serverconfig_chooser').val();
function (result) {
LdapWizard.hideSpinner('#ldap_base');
LdapWizard.showInfoBox('Please specify a Base DN');
- $('#ldap_base').prop('disabled', false);
+ LdapWizard.showInfoBox('Could not determine Base DN');
}
);
}
function (result) {
LdapWizard.hideSpinner('#ldap_port');
$('#ldap_port').prop('disabled', false);
- LdapWizard.showInfoBox('Please specify the Port');
+ LdapWizard.showInfoBox('Please specify the port');
}
);
}
functionalityCheck: function() {
//criterias to enable the connection:
- // - host, port, user filter, login filter
+ // - host, port, basedn, user filter, login filter
host = $('#ldap_host').val();
port = $('#ldap_port').val();
- userfilter = $('#ldap_dn').val();
- loginfilter = $('#ldap_agent_password').val();
+ base = $('#ldap_base').val();
+ userfilter = $('#ldap_userlist_filter').val();
+ loginfilter = $('#ldap_login_filter').val();
//FIXME: activates a manually deactivated configuration.
- if(host && port && userfilter && loginfilter) {
+ if(host && port && base && userfilter && loginfilter) {
+ LdapWizard.updateStatusIndicator(true);
if($('#ldap_configuration_active').is(':checked')) {
return;
}
$('#ldap_configuration_active').prop('checked', false);
LdapWizard.save($('#ldap_configuration_active')[0]);
}
+ LdapWizard.updateStatusIndicator(false);
}
},
init: function() {
LdapWizard.basicStatusCheck();
+ LdapWizard.functionalityCheck();
},
initGroupFilter: function() {
if($('#ldapSettings').tabs('option', 'active') == 0) {
LdapWizard.basicStatusCheck();
+ LdapWizard.functionalityCheck();
}
},
'#ldap_userfilter_groups',
'userFilterGroupSelectState'
);
+ },
+
+ updateStatusIndicator: function(isComplete) {
+ if(isComplete) {
+ LdapConfiguration.testConfiguration(
+ //onSuccess
+ function(result) {
+ $('.ldap_config_state_indicator').text(t('user_ldap',
+ 'Configuration OK'
+ ));
+ $('.ldap_config_state_indicator_sign').removeClass('error');
+ $('.ldap_config_state_indicator_sign').addClass('success');
+ },
+ //onError
+ function(result) {
+ $('.ldap_config_state_indicator').text(t('user_ldap',
+ 'Configuration incorrect'
+ ));
+ $('.ldap_config_state_indicator_sign').addClass('error');
+ $('.ldap_config_state_indicator_sign').removeClass('success');
+ }
+ );
+ } else {
+ $('.ldap_config_state_indicator').text(t('user_ldap',
+ 'Configuration incomplete'
+ ));
+ $('.ldap_config_state_indicator_sign').removeClass('error');
+ $('.ldap_config_state_indicator_sign').removeClass('success');
+ }
}
};
});
$('.ldap_action_test_connection').click(function(event){
event.preventDefault();
- $.post(
- OC.filePath('user_ldap','ajax','testConfiguration.php'),
- $('#ldap').serialize(),
- function (result) {
- if (result.status === 'success') {
- OC.dialogs.alert(
- result.message,
- t('user_ldap', 'Connection test succeeded')
- );
- } else {
- OC.dialogs.alert(
- result.message,
- t('user_ldap', 'Connection test failed')
- );
- }
+ LdapConfiguration.testConfiguration(
+ //onSuccess
+ function(result) {
+ OC.dialogs.alert(
+ result.message,
+ t('user_ldap', 'Connection test succeeded')
+ );
+ },
+ //onError
+ function(result) {
+ OC.dialogs.alert(
+ result.message,
+ t('user_ldap', 'Connection test failed')
+ );
}
);
});