Get difference between AD accountExpires and today's date

Hey everyone!

We are mapping the Active Directory accountExpires to an Identity attribute.

We need a way to find the difference between the accountExpires and today’s date and store it on another identity attribute.

We have tried the dateMath transform, but haven’t made much progress.

Thanks in advance.

check this one

1 Like

We used something like this, for every intervals that we needed:

            {
                "type": "static",
                "attributes": {
                    "requiresPeriodicRefresh": "true",
                    "testeVariavel": {
                        "type": "conditional",
                        "attributes": {
                            "firstDate": {
                                "type": "dateFormat",
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "sourceName": "AD TESTE",
                                            "attributeName": "accountExpires"
                                        }
                                    },
                                    "inputFormat": "MM/dd/yyyy hh:mm:ss a z",
                                    "outputFormat": "dd/MM/yyyy"
                                }
                            },
                            "secondDate": {
                                "type": "dateFormat",
                                "attributes": {
                                    "input": {
                                        "type": "dateMath",
                                        "roundUp": true,
                                        "attributes": {
                                            "expression": "now+1d/d"
                                        }
                                    },
                                    "inputFormat": "yyyy-MM-dd'T'HH:mm",
                                    "outputFormat": "dd/MM/yyyy"
                                }
                            },
                            "expression": "$firstDate eq $secondDate",
                            "positiveCondition": "Igual",
                            "negativeCondition": "Diferente"
                        }
                    },
                    "value": "#if($testeVariavel=='Igual')1 dia#{else}#end"
                }
            },

Thanks!

1 Like

OR try this one. We use this for the AD account to be expired at 5 pm.

{
    "name": "AD Account Expires",
    "type": "dateFormat",
    "attributes": {
        "input": {
            "attributes": {
                "expression": "+17h",
                "input": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "attributeName": "endDate",
                                "sourceName": "Active Directory - Test"
                            },
                            "type": "accountAttribute"
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm:ss'Z'",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "roundUp": false
            },
            "type": "dateMath"
        },
        "inputFormat": "yyyy-MM-dd'T'HH:mm",
        "outputFormat": "MM/dd/yyyy hh:mm:ss a z"
    },
    "internal": false
}