I'm trying to verify that user has access to the machine.
I'm trying to use LogonUser as described here:
logging.info("checking credentials")
try:
win32security.LogonUser (
name,
domain,
password,
win32security.LOGON32_LOGON_NETWORK,
win32security.LOGON32_PROVIDER_DEFAULT
)
except win32security.error, e:
logging.warn(e)
raise e
else:
logging.info('pass')
However whatever I put as name
or password
(say domain = None
) it always PASSES.
Am I missing something?
UPDATE: to reproduce:
import win32security
print win32security.LogonUser (
"asdasdasdasdfagf",
None,
"asdasdasdasdasda",
win32security.LOGON32_LOGON_NETWORK,
win32security.LOGON32_PROVIDER_DEFAULT
)
output:
<PyHANDLE at 34009576 (276)>
Though I doubt it's actually the answer you are after, the only difference I can see between what you do to test, and the way I successfully in apps I use, is the use of the LOGON32_LOGON_NETWORK
flag instead of the LOGON32_LOGON_INTERACTIVE
flag. For what our products do though, we have specific requirements for the Desktop Interactivity, and I doubt it's actually a change that'll affect your results.
def testLogin(self):
try:
LogonUser(self.wrappers['User'].GetValue(),
self.wrappers['Domain'].GetValue(),
self.wrappers['Password'].GetRawValue(),
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT)
RevertToSelf()
except Exception, e:
wx.MessageBox(unicode(e), _("Error"))
return False
return True
A domain value of None
should look to the current domain, so if you're really and truly able to run this code with any username and password on your system, then either your system has problems, or your Domain has problems.