Add some more supporting functions

Do a little bit more error handling and checking
This commit is contained in:
Rob Crittenden
2008-10-07 02:10:15 -04:00
parent cb795fa14b
commit 69bc5ad77a
4 changed files with 61 additions and 10 deletions

View File

@@ -28,7 +28,6 @@ from ipalib import api
from ipa_server import servercore
from ipa_server import ipaldap
import ldap
from ipa_server.context import context
# Command to get the idea how plugins will interact with api.env
class envtest(frontend.Command):
@@ -94,6 +93,13 @@ class user_add(crud.Add):
user['uid'] = args[0]
if not servercore.is_user_unique(user['uid']):
# FIXME, specific error
raise SyntaxError("user already exists")
if servercore.uid_too_long(user['uid']):
# FIXME, specific error
raise SyntaxError("uid is too long")
# dn is set here, not by the user
try:
del user['dn']
@@ -159,8 +165,12 @@ class user_add(crud.Add):
for u in user:
entry.setValues(u, user[u])
result = context.conn.getConn().addEntry(entry)
result = servercore.add_entry(entry)
return result
def forward(self, *args, **kw):
result = super(crud.Add, self).forward(*args, **kw)
if result != False:
print result
api.register(user_add)