Active Directory LastLogOff Attribute (Last LogOff Report)

Home | Tutorials | Compare

 

Unlike lastLogon attribute Microsoft currently does NOT utilize lastLogoff attribute [more info..]

How to Record lastLogoff time:

One solution is to log user log off time as another attribute in the active directory. By default user has permission to update certain attributes within Active Directory user object. We can use one of the listed attribute which user has permission to update as a place holder for active directory logoff date and time. In order to set the logoff attribute and view logon and logoff reports, please follow the following 3 steps:

1. Edit the setLastLogOff.vbs script file using a text editor and uncomment the attribute you aren't currently using in active directory. The uncommented attribute will be used to store the lastLogoff date and time.

2. Assign the script to run at logoff using Group Policy Editor.

3. Select the uncommented attribute while generating active directory last log on and last log off reports.

 


 

List of Attribute which user's have permission to update:
1. info
2.telephoneNumber
3. url
4. wWWHomePage
5. streetAddress
6. postOfficeBox
7. l
8. st
9. postalCode
10. homePhone
11. otherHomePhone
12. pager
13. otherPager
14. mobile
15. otherMobile
16. facsimileTelephoneNumber
17. otherFacsimileTelephoneNumber
18. ipPhone
19. otherIpPhone
20. otherHomePhone

Download setLastLogoff.vbs

'-------(setLastLogoff.vbs)---------------------------------
'This script saves user logoff date and time
'Please use Group Policy to run the script when users log off.

ON ERROR RESUME NEXT
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strlogoffTime = Cstr(Now)

'Please select any attribute from the following list
'which is not used in active directory and uncomment that line. (Just delete ' at the line start)

'objUser.otherHomePhone = strlogoffTime
'objUser.pager = strlogoffTime
'objUser.otherPager = strlogoffTime
'objUser.info = strlogoffTime
'objUser.telephoneNumber = strlogoffTime
'objUser.url = strlogoffTime
'objUser.wWWHomePage = strlogoffTime
'objUser.streetAddress = strlogoffTime
'objUser.postOfficeBox = strlogoffTime
'objUser.l = strlogoffTime
'objUser.st = strlogoffTime
'objUser.postalCode = strlogoffTime
'objUser.homePhone = strlogoffTime
'objUser.mobile = strlogoffTime
'objUser.otherMobile = strlogoffTime
'objUser.facsimileTelephoneNumber = strlogoffTime
'objUser.otherFacsimileTelephoneNumber = strlogoffTime
'objUser.ipPhone = strlogoffTime
'objUser.otherIpPhone = strlogoffTime

objUser.SetInfo


After performing step 1-2 above and logging off one time you will see the logoff value popluated in the uncommented field (pager in our case)

 

 

To run the lastLogon and lastLogOff report, select All User -> Last Logon and Last Logoff from the reports menu

 

and select the uncommented attribute from the pop-up dialog. Click OK to run the report.