diff options
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/cli.py | 18 | ||||
-rw-r--r-- | ipalib/config.py | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index 4e5e433e..a802f8ef 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -311,9 +311,25 @@ class CLI(object): break except errors.ValidationError, e: error = e.error + if self.api.env.server_context: + try: + import krbV + import ldap + from ipa_server import conn + from ipa_server.servercore import context + krbccache = krbV.default_context().default_ccache().name + context.conn = conn.IPAConn(self.api.env.ldaphost, self.api.env.ldapport, krbccache) + except ImportError: + print >> sys.stderr, "There was a problem importing a Python module: %s" % sys.exc_value + return 2 + except ldap.LDAPError, e: + print >> sys.stderr, "There was a problem connecting to the LDAP server: %s" % e[0].get('desc') + return 2 ret = cmd(**kw) if callable(cmd.output_for_cli): - cmd.output_for_cli(ret) + return cmd.output_for_cli(ret) + else: + return 0 def parse(self, cmd, argv): parser = self.build_parser(cmd) diff --git a/ipalib/config.py b/ipalib/config.py index ebd602b9..b3155490 100644 --- a/ipalib/config.py +++ b/ipalib/config.py @@ -146,6 +146,8 @@ def set_default_env(env): server_context = EnvProp(bool, True), server = LazyIter(basestring, get_servers), verbose = EnvProp(bool, False), + ldaphost = EnvProp(basestring, 'localhost'), + ldapport = EnvProp(int, 389), ) env.update(default) |