Convert Active Directory lastLogonTimestamp Format with Okta Expression Language
Last Updated:
Overview
This article explains how to convert the Active Directory attribute lastLogonTimestamp to a more readable format using the Okta Expression Language when mapped to the Okta Profile.
Applies To
- Lifecycle Management
- Active Directory (AD)
- lastLogonTime
- Okta Expression Language (OEL)
Cause
When the AD attribute lastLogonTimestamp is mapped to the Okta Profile, the format is very close to the ISO 8601 date standard but has different formatting representing the milliseconds.
This date is how AD sends the attribute value to Okta.
- 2023-07-28T22:21:49+0000
- 2023-08-28T07:00:00.000Z
Solution
The Okta Expression Language (OEL) can convert a date formatted in the ISO 8601 standard to a more readable format using time functions once the date is in the correct format.
- Use the following OEL to change the milliseconds to match the ISO 8601 date standard before converting the date to a string in a more readable format. Replace "MMM d yyy HH:mm" with the desired format as defined by the Joda time pattern.
- Time.fromIso8601ToString(String.substringBefore(appuser.lastLogonTimestamp, "+") + ".000Z","MMM d yyy HH:mm")
