diff options
author | Rob Crittenden <rcritten@redhat.com> | 2008-12-11 10:31:27 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2008-12-11 10:31:27 -0500 |
commit | e41fcf19fe82c41fe024b261d94814e092e6abaf (patch) | |
tree | 7157408d9e09fdc3bbf7d87b661fa6f315a79f42 /ipalib | |
parent | cfdd272166a2689b2f50e5df65e1304a2040633d (diff) | |
download | freeipa-e41fcf19fe82c41fe024b261d94814e092e6abaf.tar.gz freeipa-e41fcf19fe82c41fe024b261d94814e092e6abaf.tar.xz freeipa-e41fcf19fe82c41fe024b261d94814e092e6abaf.zip |
Raise an error on bad principals instead of printing one when changing passwords
Fix logic in determining what to do with an incoming principal
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/errors.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/f_passwd.py | 14 |
2 files changed, 11 insertions, 7 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py index 989721be..724654ff 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -413,6 +413,10 @@ class InsufficientAccess(GenericError): """You do not have permission to perform this task""" faultCode = 1027 +class InvalidUserPrincipal(GenericError): + """Invalid user principal""" + faultCode = 1028 + class FunctionDeprecated(GenericError): """Raised by a deprecated function""" faultCode = 2000 diff --git a/ipalib/plugins/f_passwd.py b/ipalib/plugins/f_passwd.py index edc13b63..c82cd455 100644 --- a/ipalib/plugins/f_passwd.py +++ b/ipalib/plugins/f_passwd.py @@ -52,14 +52,14 @@ class passwd(frontend.Command): :param param uid: The login name of the user being updated. :param kw: Not used. """ - if principal.find('@') < 0: + import pdb + pdb.set_trace() + if principal.find('@') > 0: u = principal.split('@') - if len(u) > 2 or len(u) == 0: - print "Invalid user name (%s)" % principal - if len(u) == 1: - principal = principal+"@"+self.api.env.realm - else: - principal = principal + if len(u) > 2: + raise errors.InvalidUserPrincipal, principal + else: + principal = principal+"@"+self.api.env.realm dn = self.Backend.ldap.find_entry_dn( "krbprincipalname", principal, |