Password Expiration Date in Email Template

We are on IIQ 8.3

I need to display the date that an AD Account Password will expire in one of our Workflow Emails. I thought to add a Process Variable of type ‘Rule’ to the Workflow and then pass that variable to the Send Email step and use it in the Template.

I’m trying to take the pwdLastSet AD value and adding 90 days to it and then return that date to be used in the EmailTemplate.

Can someone look over what I’m doing and tell me what is wrong or just that I’m perhaps doing it completely wrong?!!?

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;	

		Identity iden = context.getObjectByName(Identity.class, identityName);
		List<Link> listAccounts = iden.getLinks();
      
		if(null!=listAccounts) {
			for(Link account : listAccounts) {
				appName = account.getApplicationName();
				accountName = account.getDisplayName();

				if(appName.equalsIgnoreCase("CORP AD")){
					String empType = link.getAttribute("employeeType");
					
					if (empType.equalsIgnoreCase("Employee"){
            
						String pwdLastSet = link.getAttribute("pwdLastSet");
						
						long ninetyDaysInMillis = TimeUnit.DAYS.toMillis(90);
						long newTimeInMillis = ((pwdLastSet / 10000) - 11644473600000L) + ninetyDaysInMillis;

						LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(newTimeInMillis), ZoneId.systemDefault());
						DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
						String formattedDate = dateTime.format(formatter);
						
						return formattedDate;
					}
				}

			}
		}

Error -

sailpoint.tools.GeneralException: Exception evaluating rule: CORP Find PWD Expiry
sailpoint.tools.GeneralException: BeanShell script error: bsh.ParseException: Parse error at line 20, column 104.  Encountered: ; BSF info: YSI Find PWD Expiry at line: 0 column: columnNo

Thanks for any assistance!!

String pwdLastSet should be of type long:
long pwdLastSet = Long.parseLong(link.getAttribute("pwdLastSet"));

The if statement has a missing closing parenthesis:
Incorrect: if (empType.equalsIgnoreCase("Employee")
Correct: if (empType.equalsIgnoreCase("Employee"))

1 Like

closing parenthesis missing for below line :
if (empType.equalsIgnoreCase(“Employee”){

1 Like

Hi and Hello,

Try and give info.


import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
import java.util.List;

// Retrieve Identity object
iden = context.getObjectByName(Identity.class, identityName);
listAccounts = iden.getLinks();

if (listAccounts != null) {
    for (account : listAccounts) {
        appName = account.getApplicationName();
        accountName = account.getDisplayName();

        if (appName.equalsIgnoreCase("CORP AD")) {
            empType = account.getAttribute("employeeType");

            // Fixed syntax error in if statement
            if (empType != null && empType.equalsIgnoreCase("Employee")) {

                pwdLastSetStr = account.getAttribute("pwdLastSet");

                if (pwdLastSetStr != null) {
                    try {
                        pwdLastSet = Long.parseLong(pwdLastSetStr);

                        ninetyDaysInMillis = TimeUnit.DAYS.toMillis(90);
                        newTimeInMillis = ((pwdLastSet / 10000) - 11644473600000L) + ninetyDaysInMillis;

                        dateTime = LocalDateTime.ofInstant(
                            Instant.ofEpochMilli(newTimeInMillis),
                            ZoneId.systemDefault()
                        );

                        formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        formattedDate = dateTime.format(formatter);

                        return formattedDate;

                    } catch (Exception e) {
                        throw new GeneralException("Error converting pwdLastSet: " + pwdLastSetStr);
                    }
                }
            }
        }
    }
}

Regards,
Adam

5 Likes

I wish I could mark several posts as solutions!! Thank you for your help, it really means a lot as I keep trying to learn all of this! Your time and sharing of knowledge are truly appreciated.

Thanks again!!!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.