LDAP: implement deleteConfiguration feature
This commit is contained in:
parent
3bf38c7a84
commit
5b9e181198
|
@ -45,12 +45,32 @@ var LdapConfiguration = {
|
|||
$(this).removeAttr('checked');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
deleteConfiguration: function() {
|
||||
$.post(
|
||||
OC.filePath('user_ldap','ajax','deleteConfiguration.php'),
|
||||
$('#ldap_serverconfig_chooser').serialize(),
|
||||
function (result) {
|
||||
if(result.status == 'success') {
|
||||
$('#ldap_serverconfig_chooser option:selected').remove();
|
||||
$('#ldap_serverconfig_chooser option:first').select();
|
||||
LdapConfiguration.refreshConfig();
|
||||
} else {
|
||||
OC.dialogs.alert(
|
||||
result.message,
|
||||
'Deletion failed'
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#ldapSettings').tabs();
|
||||
$('#ldap_action_test_connection').button();
|
||||
$('#ldap_action_delete_configuration').button();
|
||||
LdapConfiguration.refreshConfig();
|
||||
$('#ldap_action_test_connection').click(function(event){
|
||||
event.preventDefault();
|
||||
|
@ -73,6 +93,19 @@ $(document).ready(function() {
|
|||
);
|
||||
});
|
||||
|
||||
$('#ldap_action_delete_configuration').click(function(event) {
|
||||
event.preventDefault();
|
||||
OC.dialogs.confirm(
|
||||
'Do you really want to delete the current Server Configuration?',
|
||||
'Confirm Deletion',
|
||||
function(deleteConfiguration) {
|
||||
if(deleteConfiguration) {
|
||||
LdapConfiguration.deleteConfiguration();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$('#ldap_submit').click(function(event) {
|
||||
event.preventDefault();
|
||||
$.post(
|
||||
|
|
|
@ -62,5 +62,32 @@ class Helper {
|
|||
|
||||
return $prefixes;
|
||||
}
|
||||
|
||||
static public function deleteServerConfiguration($prefix) {
|
||||
//just to be on the safe side
|
||||
\OCP\User::checkAdminUser();
|
||||
|
||||
if(!in_array($prefix, self::getServerConfigurationPrefixes())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = \OCP\DB::prepare('
|
||||
DELETE
|
||||
FROM `*PREFIX*appconfig`
|
||||
WHERE `configkey` LIKE ?
|
||||
AND appid = "user_ldap"
|
||||
');
|
||||
$res = $query->execute(array($prefix.'%'));
|
||||
|
||||
if(\OCP\DB::isError($res)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($res->numRows() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
<p><label for="ldap_serverconfig_chooser"><?php echo $l->t('Server configuration');?></label><select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
|
||||
<?php echo $_['serverConfigurationOptions']; ?>
|
||||
<option value="NEW"><?php echo $l->t('Add Server Configuration');?></option>
|
||||
</select></p>
|
||||
</select>
|
||||
<button id="ldap_action_delete_configuration" name="ldap_action_delete_configuration">Delete Configuration</button>
|
||||
</p>
|
||||
<p><label for="ldap_host"><?php echo $l->t('Host');?></label><input type="text" id="ldap_host" name="ldap_host" value="<?php echo $_['ldap_host']; ?>" data-default="<?php echo $_['ldap_host_default']; ?>" title="<?php echo $l->t('You can omit the protocol, except you require SSL. Then start with ldaps://');?>"></p>
|
||||
<p><label for="ldap_base"><?php echo $l->t('Base DN');?></label><textarea id="ldap_base" name="ldap_base" placeholder="<?php echo $l->t('One Base DN per line');?>" title="<?php echo $l->t('You can specify Base DN for users and groups in the Advanced tab');?>" data-default="<?php echo $_['ldap_base_default']; ?>" ><?php echo $_['ldap_base']; ?></textarea></p>
|
||||
<p><label for="ldap_dn"><?php echo $l->t('User DN');?></label><input type="text" id="ldap_dn" name="ldap_dn" value="<?php echo $_['ldap_dn']; ?>" data-default="<?php echo $_['ldap_dn_default']; ?>" title="<?php echo $l->t('The DN of the client user with which the bind shall be done, e.g. uid=agent,dc=example,dc=com. For anonymous access, leave DN and Password empty.');?>" /></p>
|
||||
|
|
Loading…
Reference in New Issue