Fix traceback and incorrect message when resolving an unresolvable SID

This commit is contained in:
Morgan Willcock 2017-10-26 19:31:56 +01:00
parent 8787d02688
commit 9572aabb67

View file

@ -1133,7 +1133,7 @@ def get_name(principal):
try:
return win32security.LookupAccountSid(None, sid_obj)[0]
except TypeError:
except (pywintypes.error, TypeError):
raise CommandExecutionError(
'Could not find User for {0}'.format(principal))
@ -1173,7 +1173,7 @@ def get_owner(obj_name):
owner_sid = 'S-1-1-0'
else:
raise CommandExecutionError(
'Failed to set permissions: {0}'.format(exc.strerror))
'Failed to get owner: {0}'.format(exc.strerror))
return get_name(win32security.ConvertSidToStringSid(owner_sid))