<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007UgGYeCANOkta Identity EngineWorkflowsAnswered2024-04-03T16:09:08.000Z2022-03-08T01:04:35.000Z2022-03-08T22:10:32.000Z

MatthewH.10249 (State of Iowa) asked a question.

Active Directory date conversion

How can I convert a date like "133905492000000000" found in a user profile attribute (ADaccountExpires) from Active Directory to something usable in an Okta Workflow. I want to create a workflow to that can look at users about to expire by this date and send them or their managers an email to inform them before it is too late and their account gets suspended.


  • Hi @MatthewH.10249 (State of Iowa)​,

     

    This was an interesting one... I think I have a solution for you, though.

     

    I had to do some research on the time format, and found this doc from MSFT as well as this StackOverflow question.

     

    The Active Directory stores date/time values as the number of 100-nanosecond intervals that have elapsed since the 0 hour on January 1, 1601 until the date/time that is being stored. The time is always stored in Greenwich Mean Time (GMT) in the Active Directory. - from MSFT.

     

    Based on what I found, I came up with the following:

    AD Date Conversion Workflow

    1. Use a Number - Divide card to divide your AD date by 10,000.
    2. Use a Date & Time - Add card with a start date of 1601-01-01T00:00:00Z and add the result from the Number - Divide card with a unit of milliseconds.

     

    I then attempted to validate the result using this tool, and it appears that the result is correct and in a format that you can leverage with Okta's APIs and Workflows.

    Expand Post
    Selected as Best
  • Hi @MatthewH.10249 (State of Iowa)​,

     

    This was an interesting one... I think I have a solution for you, though.

     

    I had to do some research on the time format, and found this doc from MSFT as well as this StackOverflow question.

     

    The Active Directory stores date/time values as the number of 100-nanosecond intervals that have elapsed since the 0 hour on January 1, 1601 until the date/time that is being stored. The time is always stored in Greenwich Mean Time (GMT) in the Active Directory. - from MSFT.

     

    Based on what I found, I came up with the following:

    AD Date Conversion Workflow

    1. Use a Number - Divide card to divide your AD date by 10,000.
    2. Use a Date & Time - Add card with a start date of 1601-01-01T00:00:00Z and add the result from the Number - Divide card with a unit of milliseconds.

     

    I then attempted to validate the result using this tool, and it appears that the result is correct and in a format that you can leverage with Okta's APIs and Workflows.

    Expand Post
    Selected as Best
  • TimL.58332 (Workflows)

    You can also "reverse" it in workflows like such:

     

    image 

    Will result in same value as Bryan's start above (133905492000000000). This could be useful if you want to lets say "Only evaluate users after/before" a certain date. You could then LT/GT the AD attribute value as a number instead of translating it into a date.

    Expand Post
    • MatthewH.10249 (State of Iowa)

      This was exactly what I was going to do next so thanks for the beating me to it! 🙂

This question is closed.
Loading
Active Directory date conversion