netcmd: Improve error handling of gpo aclcheck as non-admin
commit5bfad1b2b08031b99834c9ca39c1900d52c8eb0d
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 29 Jan 2019 00:25:55 +0000 (29 13:25 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Feb 2019 02:36:17 +0000 (1 03:36 +0100)
tree042e8c8500570a42cac896eb549b7a83de0ef543
parent1e0db9726bb91ff967c896686d129aa30563697d
netcmd: Improve error handling of gpo aclcheck as non-admin

Reading the nTSecurityDescriptor attribute over LDAP requires admin
creds. However, if you don't specify admin creds, then you get an error
like this:

bin/samba-tool gpo aclcheck
ERROR(<class 'KeyError'>): uncaught exception - 'No such element'
  File "bin/python/samba/netcmd/__init__.py", line 184, in _run
    return self.run(*args, **kwargs)
  File "bin/python/samba/netcmd/gpo.py", line 1536, in run
    ds_sd_ndr = m['nTSecurityDescriptor'][0]

This patch adds an explicit check/error message to make the problem
clearer.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/gpo.py