Find the full name from the Contact record if it is filled in from the "userPrincipalName" field

In my integration v9.50 Connect it 9.80 Contact name = Operator name and not equal to their username in LDAP.
Instead, the Contact and Operator are called the "userPrincipalName" field from the LDAP field of the user card.
This is done in order to avoid the conflict of identical usernames. A company has a large staff of employees, sometimes the names are completely the same, but they are different people.
"userPrincipalName" is always unique in our domain. Therefore, I divided the users according to this field.
But there was a problem with the real username, which needs to be specified in the registration messages "Interactions" when creating via SmartEmail.
The full username is filled only in the "Full Name" in the "Contact" record of the user.

I solve this problem with the function in the SmartEmailSecurityUtils library:

/**
*   get fullname info by contact name
*
*   @param {contactName} - contact name(userPrincipalName)
*   @return - contact full name
**/

function findContactName( contactName ){
 var contact=new SCFile("contacts", SCFILE_READONLY);
    var rc=contact.doSelect("contact.name=\"" contactName "\"");
    if (rc == RC_SUCCESS) {
    var fullname = contact['full.name'];
    	return fullname;
    } else {
    	return null;
    }
    return null;
}

Also, add variables to the HTML-template:

//#################################################################################################################

//for the .assigne template $RECORD.contact_fullname = lib.SmartEmailSecurityUtils.findContactName($RECORD.contact_name);
//for the .fulfilled template assinee_fullname = lib.SmartEmailSecurityUtils.findContactName($RECORD.assignee_name);
//#################################################################################################################

Of course, this is not the most beautiful decision, but it helped me.
Hope to help someone else.