Agent: fix access denied error handling in wmi_tools.py

This commit is contained in:
vakaris_zilius 2022-03-10 10:18:35 +00:00
parent 27e3cc6b4c
commit d9ee377945
1 changed files with 6 additions and 2 deletions

View File

@ -64,9 +64,13 @@ class WmiTools(object):
wmi.CLSID_WbemLevel1Login, wmi.IID_IWbemLevel1Login wmi.CLSID_WbemLevel1Login, wmi.IID_IWbemLevel1Login
) )
except Exception as exc: except Exception as exc:
try:
dcom.disconnect() dcom.disconnect()
except KeyError:
# No connection to disconnect
pass
if "rpc_s_access_denied" == exc: if "rpc_s_access_denied" == exc.error_string:
raise AccessDeniedException(host, username, password, domain) raise AccessDeniedException(host, username, password, domain)
raise raise