Move some functionality from user-add to the backend ldap create function

This commit is contained in:
Rob Crittenden
2008-10-14 17:46:36 -04:00
parent 9788800aa4
commit 30664cde88
5 changed files with 63 additions and 71 deletions
+17 -1
View File
@@ -25,7 +25,11 @@ This wraps the python-ldap bindings.
import ldap as _ldap
from ipalib import api
from ipalib import errors
from ipalib.crud import CrudBackend
from ipa_server import servercore
from ipa_server import ipaldap
import ldap
class ldap(CrudBackend):
@@ -46,6 +50,18 @@ class ldap(CrudBackend):
)
def create(self, **kw):
return kw
if servercore.entry_exists(kw['dn']):
raise errors.DuplicateEntry("entry already exists")
entry = ipaldap.Entry(kw['dn'])
# dn isn't allowed to be in the entry itself
del kw['dn']
# Fill in our new entry
for k in kw:
entry.setValues(k, kw[k])
return servercore.add_entry(entry)
api.register(ldap)