How to Get Last logon date
Keywords: wntUserGetDat
Question:
Hi all - I'm trying to determine the last logon date / time for each user on an NT4 network. I've looked at the various Winbatch (97D) functions like wNTUserxxx but can't spot a way of doing it. (I know I have to interrogate each BDC because the PDC database isn't up to date at any given time).Can you help please?
Answer:
UmmmwntUserGetDat from the "The list of fixes and improvements file":
Added new "elements" to wntUserGetDat: "last_logon" (s): last logon time, in "YYYY:MM:DD:hh:mm:ss" format "last_logoff" (s): last logoff time, in "YYYY:MM:DD:hh:mm:ss" format These times are maintained separately on each Backup Domain Controller (BDC) in the domain. To get an accurate value, each BDC in the domain must be queried, and the largest value is used. The return value will always contain a 4-digit year. If no value is available, "0000:00:00:00:00:00" is returned. Note: These elements cannot be set using wntUserAddDat or wntUserSetDat.In the 98-99 version of WinBatch:wntUserGetDat(server, user, "last_logon")Returns time in "YYYY:MM:DD:hh:mm:ss" format. Needs WinBatch 98D or higher. See FIXES text file for more info. These times are maintained separately on each Backup Domain Controller (BDC) in the domain. To get an accurate value, each BDC in the domain must be queried, and the largest value is used.The return value will always contain a 4-digit year. If no value is available, "0000:00:00:00:00:00" is returned.
Note: These elements cannot be set using wntUserAddDat or wntUserSetDat.
Article ID: W14272Filename: wxxUserGetDat and Last Logon Date.txt