domain_remove function

This commit is contained in:
Kloadut 2012-10-29 17:47:37 +01:00
parent cbd61fc3bc
commit f38f99f6a7
3 changed files with 31 additions and 2 deletions

View file

@ -92,7 +92,7 @@ user:
arguments:
users:
help: Username of users to delete
nargs: "+"
nargs: "*"
--purge:
action: store_true
@ -184,7 +184,7 @@ domain:
arguments:
domain:
help: Domain(s) to delete
nargs: "+"
nargs: "*"
### domain_info()
info:

View file

@ -72,3 +72,31 @@ def domain_add(args, connections):
return { 'Domains' : result }
def domain_remove(args, connections):
"""
Remove domain from LDAP
Keyword argument:
args -- Dictionnary of values
connections -- LDAP connection
Returns:
Dict
"""
yldap = connections['ldap']
result = []
args = get_required_args(args, { 'domain' : _('Domain to remove') })
if not isinstance(args['domain'], list):
args['domain'] = [ args['domain'] ]
for domain in args['domain']:
validate({ domain : r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' })
if yldap.remove('virtualdomain=' + domain + ',ou=domains'):
result.append(domain)
continue
else:
raise YunoHostError(169, _("An error occured during domain deletion"))
win_msg(_("Domain(s) successfully deleted"))
return { 'Domains' : result }

View file

@ -159,6 +159,7 @@ def user_delete(args, connections):
yldap = connections['ldap']
result = { 'Users' : [] }
args = get_required_args(args, { 'users' : _('User to delete') })
if not isinstance(args['users'], list):
args['users'] = [ args['users'] ]