Does win32security.LogonUser() Update Last Logon Timestamp?
Question: I'm writing a Python script that will automatically logon users from a list.
This script will be run once a month to prevent accounts from being disabled
due to low activity. Below is the working code:

    
    
    import win32security
    import getpass
    accounts = {'user1':'password1', 'user2':'password2', 'user3':'password3'}
    for username, password in accounts.items():
        handle = win32security.LogonUser(username, "DOMAIN", password, win32security.LOGON32_LOGON_INTERACTIVE, win32security.LOGON32_PROVIDER_DEFAULT)
        print username.upper() + ': ' + repr(bool(handle))
        handle.close()
    

My question is, would the win32security.LogonUser() update the "last logged
on" timestamp in Active Directory? Is there another way to achieve this
without having administrative rights to the Active Directory server?

Thanks

Wole


Answer: The interactive logon call you're making should update this. There's no way to
manually update the value even with administrative rights, though as an FYI.

