oschmod icon indicating copy to clipboard operation
oschmod copied to clipboard

Exception on Windows machines which are members of a domain but not connected to a domain controller

Open nfd opened this issue 5 years ago • 1 comments

Describe the bug

Calling get_mode on a Windows machine which is a member of a domain but which is disconnected from its domain controller produces an exception from win32security.LookupAccountSid().

Your configuration

Windows 10 x64, Python 3.7, oschmod==0.3.9

Steps to reproduce

oschmod.get_mode(pathname)

What happened

Traceback (most recent call last)
File "...\oschmod\__init__.py", line 163, in get_mode
    return win_get_permissions(path)
File "...\oschmod\__init__.py", line 364, in win_get_permissions
    return _win_get_permissions(path, get_object_type(path))
File "...\oschmod\__init__.py", line 387, in _win_get_permissions
    win32security.LookupAccountSid(None, ace[2]) != \
pywintypes.error: (1789, 'LookupAccountSid', 'The trust relationship between this workstation and the primary domain controller failed.')

Additional context I'm not an expert in windows security (traceback was retyped from a screenshot of a teamviewer session!) so am not sure if this is even resolvable or oschmod's problem. But apparently being part of a domain, but not connected to a domain controller, is a reasonable scenario for Windows devices.

nfd avatar Nov 04 '20 12:11 nfd

Thanks for raising this issue! My apologies for not getting back to you. I'll definitely take a look at this. Perhaps there's some easy error handling that will allow this to work despite the exception.

YakDriver avatar Dec 02 '20 15:12 YakDriver