Okta Expression to get a positioned value from user DN
We are trying to get OU name from user distinguishedname attribute to a custom attribute. User DN eg:- CN=Nidhin C K,OU=Users,OU=XXX,OU=XX,DC=region,DC=dc,DC=company,DC=com
From this above value we just need to pull XXX (its position will not change, ie no of characters from right to left won't change).
we cannot use String.substring(appuser.dn, 2, 9) as this command calculate value from left to right. In our scenario "OU=XXX,OU=XX,DC=region,DC=dc,DC=company,DC=com" is constant. ie its position or no of characters wont change.
Is there a way to get only XXX from user DN using expression
Linked below is Okta's documentation on the Expression Language: https://developer.okta.com/reference/okta_expression_language/
From what you described, it sounds like String.substring function would work, but the position from left to right will always be different, given the CN will be different dependon on the users name. So perhaps we could make String.substring work, if we could remove the CN portion of the string first.
Try including String.substringAfter(appuser.dn, "OU=Users,")
Once that portion of the string is removed, you can then use the String.substring function.