summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-10-07 23:38:00 -0400
committerRob Crittenden <rcritten@redhat.com>2008-10-10 03:36:56 -0400
commit672c07566df8d838b46edb6b80ba73ade2a27d55 (patch)
tree9062328ba7df3fb02ca01843ee1775d559fea10c
parent3e505cc908444e04b7ad6843c3b54cfd0ded05f3 (diff)
downloadfreeipa-672c07566df8d838b46edb6b80ba73ade2a27d55.tar.gz
freeipa-672c07566df8d838b46edb6b80ba73ade2a27d55.tar.xz
freeipa-672c07566df8d838b46edb6b80ba73ade2a27d55.zip
Implement user-del
rename is_user_unique() to user_exists()
-rw-r--r--ipa_server/servercore.py11
-rw-r--r--ipalib/plugins/f_user.py27
2 files changed, 34 insertions, 4 deletions
diff --git a/ipa_server/servercore.py b/ipa_server/servercore.py
index f0d3dd9aa..a391c5cf9 100644
--- a/ipa_server/servercore.py
+++ b/ipa_server/servercore.py
@@ -134,9 +134,10 @@ def get_entry_by_dn (dn, sattrs=None):
# User support
-def is_user_unique(uid):
- """Return True if the uid is unique in the tree, False otherwise."""
- # FIXME
+def user_exists(uid):
+ """Return True if the exists, False otherwise."""
+ # FIXME: fix the filter
+ # FIXME: should accept a container to look in
# uid = self.__safe_filter(uid)
searchfilter = "(&(uid=%s)(objectclass=posixAccount))" % uid
@@ -292,6 +293,10 @@ def add_entry(entry):
"""Add a new entry"""
return context.conn.getConn().addEntry(entry)
+def delete_entry(dn):
+ """Remove an entry"""
+ return context.conn.getConn().deleteEntry(dn)
+
def uniq_list(x):
"""Return a unique list, preserving order and ignoring case"""
myset = {}
diff --git a/ipalib/plugins/f_user.py b/ipalib/plugins/f_user.py
index b006c24b2..f87ddea1f 100644
--- a/ipalib/plugins/f_user.py
+++ b/ipalib/plugins/f_user.py
@@ -93,7 +93,7 @@ class user_add(crud.Add):
user['uid'] = args[0]
- if not servercore.is_user_unique(user['uid']):
+ if servercore.user_exists(user['uid']):
# FIXME, specific error
raise SyntaxError("user already exists")
if servercore.uid_too_long(user['uid']):
@@ -177,6 +177,31 @@ api.register(user_add)
class user_del(crud.Del):
'Delete an existing user.'
+ def execute(self, *args, **kw):
+ """args[0] = uid of the user to remove
+
+ Delete a user. Not to be confused with inactivate_user. This
+ makes the entry go away completely.
+
+ uid is the uid of the user to delete
+
+ The memberOf plugin handles removing the user from any other
+ groups.
+ """
+ uid = args[0]
+ if uid == "admin":
+ raise ipaerror.gen_exception(ipaerror.INPUT_ADMIN_REQUIRED)
+# logging.info("IPA: delete_user '%s'" % uid)
+ user = servercore.get_user_by_uid(uid, ['dn', 'uid'])
+ if not user:
+ # FIXME, specific error
+ raise SyntaxError("user doesn't exist")
+
+ return servercore.delete_entry(user['dn'])
+ def forward(self, *args, **kw):
+ result = super(crud.Del, self).forward(*args, **kw)
+ if result != False:
+ print "User %s removed" % args[0]
api.register(user_del)