From b27543aa729ca893270831d5c4fc74ea7ac6d407 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Wed, 5 Feb 2014 15:29:18 +1300 Subject: provision: improve error message when connecting to samdb without the correct permissions Signed-off-by: Garming Sam Signed-off-by: Andrew Bartlett Reviewed-by: Andrew Bartlett Reviewed-by: Jelmer Vernooij --- python/samba/provision/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py index c0735d3a58b..fc9e0bed75c 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py @@ -1203,7 +1203,13 @@ def setup_samdb(path, session_info, provision_backend, lp, names, # And now we can connect to the DB - the schema won't be loaded from the # DB - samdb.connect(path) + try: + samdb.connect(path) + except ldb.LdbError, (num, string_error): + if (num == ldb.ERR_INSUFFICIENT_ACCESS_RIGHTS): + raise ProvisioningError("Permission denied connecting to %s, are you running as root?" % path) + else: + raise # But we have to give it one more kick to have it use the schema # during provision - it needs, now that it is connected, to write -- cgit