<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
System Status
Announcements
Announcements
Search
Search
Select Language
0D54z0000A6djecCQAOkta Classic EngineSingle Sign-OnAnswered2026-10-26T20:08:38.000Z2024-04-22T17:12:31.000Z2026-10-26T20:08:38.000Z

sogi1 (sogi1) asked a question.

okta expression language - trying to extract groups using an AND condition

 

Arrays.contains(access.scope, "groups-MEP-core") ? Groups.startsWith("active_directory","ldap-amw-abopayments-",100) AND Groups.endsWith("active_directory","-dev",100)


  • Paul S. (Okta, Inc.)

    Updating this response for ease of access and reference: 

     

    Overview

    This article discusses using Okta Expression Language (OEL) to extract groups using an AND condition. Specifically, it addresses attempting to filter groups that both start with and end with specific strings.

     

    Applies To

    • Okta Identity Engine (OIE)
    • Okta Classic Engine
    • Okta Expression Language (OEL)
    • Active Directory (AD)

     

    Solution

    How does Okta extract groups using multiple conditions in Okta Expression Language?

    Evaluate a conditional expression that attempts to extract Active Directory (AD) groups starting with a specific prefix and ending with a specific suffix using an AND operator.

    1. Arrays.contains(access.scope, "groups-MEP-core") ? Groups.startsWith("active_directory","ldap-amw-abopayments-",100) AND Groups.endsWith("active_directory","-dev",100)

    Extract groups that meet multiple conditions without a conditional statement by using the Arrays.flatten function to combine the results of the Groups.startsWith and Groups.endsWith functions.

    1. Arrays.flatten(Groups.startsWith("active_directory","ldap-amw-abopayments-",100), Groups.endsWith("active_directory","-dev",100))

    NOTE: This expression returns a union of the groups, meaning it lists all groups that start with the first string and all groups that end with the second string. It does not return an intersection of groups that meet both conditions simultaneously.

    Combine the flattened arrays using an AND operator to attempt filtering the groups further.

    1. Arrays.flatten(Groups.startsWith("active_directory","ldap-amw-abopayments-",100)) AND Arrays.flatten(Groups.endsWith("active_directory","-dev",100))

    NOTE: This alternative expression also returns a union of the groups rather than an intersection.

     

    Related References

     

    Expand Post
    Selected as Best
  • Mihai N. (Okta, Inc.)

    Hi @sogi1 (sogi1)​ , Thank you for reaching out to the Okta Community! 

     

    Please provide the context for the use of this expression as not everything is supported everywhere. 

    Also, is this for use in attribute mapping, group rules, something else? 

     

     

    Regards.

     

    --

    Help others in the community by liking or hitting Select as Best if this response helped you.

    Expand Post
  • sogi1 (sogi1)

    we are using this in a claim to push back groups that a user is in. We want to send in the claim all the groups a user is in that starts with ldap-amw-abopayments- and ends with -dev .

  • sogi1 (sogi1)

    Thank you for your quick reply. i tried it just as you have it in the array.flatten and it still returns all groups a user is in that starts-with so its only listing all the startswith groups

    Image is not available

    Expand Post
    • Mihai N. (Okta, Inc.)

      Ok, so if Arrays.flatten worked for the first part, let's try a combination  

       

      Arrays.flatten(Groups.startsWith("active_directory","ldap-amw-abopayments-",100)) AND Arrays.flatten(Groups.endsWith("active_directory","-dev",100))

       

      If this does not work, I recommend opening a case to go over things with one my colleagues from the Support team.  

       

       

      Regards.

      --

      Help others in the community by liking or hitting Select as Best if this response helped you.

      Expand Post
  • sogi1 (sogi1)

    thank you for your help. This 'AND' statement works but it gives me the groups that start with and the groups that end with but it doesn't combine the too. What I am wanting is an also. groups that are

    ldap-amw-abopayments*-dev (anything after payments and ends with dev). thanks again for helping

    • Mihai N. (Okta, Inc.)

      Hmm, I would have said to use a regex function but that returns a boolean. 

      Unfortunately, I'm not seeing a way to achieve this.

      I recommend opening a case to go over things with one of my colleagues from the Support team.

       

       

      Regards.

      --

      Help others in the community by liking or hitting Select as Best if this response helped you.

      Expand Post
  • Paul S. (Okta, Inc.)

    Updating this response for ease of access and reference: 

     

    Overview

    This article discusses using Okta Expression Language (OEL) to extract groups using an AND condition. Specifically, it addresses attempting to filter groups that both start with and end with specific strings.

     

    Applies To

    • Okta Identity Engine (OIE)
    • Okta Classic Engine
    • Okta Expression Language (OEL)
    • Active Directory (AD)

     

    Solution

    How does Okta extract groups using multiple conditions in Okta Expression Language?

    Evaluate a conditional expression that attempts to extract Active Directory (AD) groups starting with a specific prefix and ending with a specific suffix using an AND operator.

    1. Arrays.contains(access.scope, "groups-MEP-core") ? Groups.startsWith("active_directory","ldap-amw-abopayments-",100) AND Groups.endsWith("active_directory","-dev",100)

    Extract groups that meet multiple conditions without a conditional statement by using the Arrays.flatten function to combine the results of the Groups.startsWith and Groups.endsWith functions.

    1. Arrays.flatten(Groups.startsWith("active_directory","ldap-amw-abopayments-",100), Groups.endsWith("active_directory","-dev",100))

    NOTE: This expression returns a union of the groups, meaning it lists all groups that start with the first string and all groups that end with the second string. It does not return an intersection of groups that meet both conditions simultaneously.

    Combine the flattened arrays using an AND operator to attempt filtering the groups further.

    1. Arrays.flatten(Groups.startsWith("active_directory","ldap-amw-abopayments-",100)) AND Arrays.flatten(Groups.endsWith("active_directory","-dev",100))

    NOTE: This alternative expression also returns a union of the groups rather than an intersection.

     

    Related References

     

    Expand Post
    Selected as Best
This question is closed.
Loading
okta expression language - trying to extract groups using an AND condition
Okta Support Agent (Beta)

Terms of Service

Hello! I'm the Okta Support Agent (Beta), your go-to resource for questions about Okta products. Please remember for your security and privacy, do not share any Personally Identifiable Information (PII) such as passwords, IP addresses, or other details with me.

Okta Privacy Policy and Terms of Service apply