diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-05-11 04:00:30 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-05-29 00:38:40 -0400 |
commit | 51bd68eaf5e2b21ce79f6b848a67f88abe9f7e11 (patch) | |
tree | f178554d6ac5f5c2e35d3a14827f24dc3fc02017 /ipalib/plugins/baseldap.py | |
parent | 1af36da933cd3c788e3a48257e2f5c286e985e22 (diff) | |
download | freeipa-51bd68eaf5e2b21ce79f6b848a67f88abe9f7e11.tar.gz freeipa-51bd68eaf5e2b21ce79f6b848a67f88abe9f7e11.tar.xz freeipa-51bd68eaf5e2b21ce79f6b848a67f88abe9f7e11.zip |
Provide a better error message when deleting nonexistent attributes
If --delattr is used on an attribute that's not present on an entry,
and --{set,add}attr isn't being used on that same attribute,
say that there's "no such attribute" instead of "<attribute> does
not contain <value>".
https://fedorahosted.org/freeipa/ticket/2699
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 7664928be..58d53fd0d 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -906,6 +906,16 @@ last, after all sets and adds."""), ) except errors.NotFound: self.obj.handle_not_found(*keys) + + # Provide a nice error message when user tries to delete an + # attribute that does not exist on the entry (and user is not + # adding it) + names = set(n.lower() for n in old_entry) + del_nonexisting = delattrs - (names | setattrs | addattrs) + if del_nonexisting: + raise errors.ValidationError(name=del_nonexisting.pop(), + error=_('No such attribute on this entry')) + for attr in needldapattrs: entry_attrs[attr] = old_entry.get(attr, []) |