diff options
Diffstat (limited to 'ipa_server/plugins/b_ldap.py')
-rw-r--r-- | ipa_server/plugins/b_ldap.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ipa_server/plugins/b_ldap.py b/ipa_server/plugins/b_ldap.py index 69c2aeb5..600f1c86 100644 --- a/ipa_server/plugins/b_ldap.py +++ b/ipa_server/plugins/b_ldap.py @@ -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) |