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

有帮助吗?

解决方案

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.

其他提示

Any Interactive login, file service access, or exchange server access, will update the LastLogon, and thus the LastLogonTimestamp, which is manged by the DS Server, and kept within 10 days accuracy.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top