LoginUser API access from Python
Question: Is there a way to call the following method from Python?

<http://msdn.microsoft.com/en-
us/library/windows/desktop/aa378184(v=vs.85).aspx>

Any help would be greatly appreciated.


Answer: You may use [ctypes](http://docs.python.org/2/library/ctypes.html). This
example seems to work (Python 2.7):

    
    
    from ctypes import *
    from ctypes.wintypes import HANDLE
    
    # Example use of WinAPI
    windll.user32.MessageBoxW(None, u"Example", u"Example", 0)
    
    x = HANDLE()
    print windll.advapi32.LogonUserW(u"Tupteq", None, u"passwd", 4, 0, pointer(x))
    print windll.kernel32.GetLastError()
    print x
    

In my case `GetLastError()` returned `1326` in case of bad password and `1327`
when password was correct.

You may need to adjust values of `dwLogonType` and `dwLogonProvider`.

