Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] No Mapping between account names and Security Id was done #1875

Closed
vikilpet opened this issue Nov 13, 2020 · 0 comments
Closed

[Windows] No Mapping between account names and Security Id was done #1875

vikilpet opened this issue Nov 13, 2020 · 0 comments

Comments

@vikilpet
Copy link

vikilpet commented Nov 13, 2020

Windows Sever 2012 R2 Standard

  • Microsoft Windows [Version 6.3.9600]
  • psutil version: 5.7.3
  • python version Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) 32-bit
    Terminal server

Bug description
Python with elevated privileges

>>> import psutil
>>> for p in psutil.process_iter(ad_value=''): print(p.username())
NT AUTHORITY\SYSTEM
NT AUTHORITY\SYSTEM
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\psutil\__init__.py", line 715, in username
    return self._proc.username()
  File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\psutil\_pswindows.py", line 681, in wrapper
    raise convert_oserror(err, pid=self.pid, name=self._name)
  File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\psutil\_pswindows.py", line 671, in convert_oserror
    raise exc
  File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\psutil\_pswindows.py", line 679, in wrapper
    return fun(self, *args, **kwargs)
  File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\psutil\_pswindows.py", line 926, in username
    domain, user = cext.proc_username(self.pid)
OSError: [WinError 1332] No Mapping between account names and Security Id was done: '(originated from LookupAccountSidW)'

These bad processes are 'dwm.exe' of non-admin remote desktop users.
It can be monkey patched like that, in _pswindows.py:

    try:
        domain, user = cext.proc_username(self.pid)
    except OSError:
        domain, user = '-', '-'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants