--- title: "User claim scripts" slug: "user-claim-scripts-v7-0" description: "Learn about user claims, scripts, and default mappings to optimize entitlements and enhance security in your identity management policies." tags: ["User Claims", "User Claim Scripts", "Scripts"] updated: 2026-06-05T19:17:41Z published: 2026-06-05T19:17:41Z canonical: "support.appgate.com/user-claim-scripts-v7-0" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.appgate.com/llms.txt > Use this file to discover all available pages before exploring further. # User claim scripts ## User claims User claims are criteria used in policies to control which users receive entitlements. You can also use user claims in conditions to decide when entitlements are allowed. AppGate ZTNA maps a set of default identity provider (IdP) database attributes to user claims. The mapped attributes depend on the IdP type. You can change the default mappings and create new user claims mapped from other attributes. By creating multiple policy expressions that use different claims, you can allocate entitlements precisely and reduce overprovisioning. --- ## User claim scripts User claim scripts create additional user claims. They run after user sign-in and after device claim scripts, but before policy assignment. Scripts can use existing user, device, and system claims, and any additional user claims they generate can be used elsewhere in the system. On the Controller, new claims can be used as policy assignment criteria and are added to the claims token. On the Gateway, they can be used as access criteria in conditions and in entitlement scripts to define protected hosts. Use this script type to query external systems and collect additional information about the user or their device. We recommend using user claim scripts for external calls instead of assignment criteria scripts because user claim scripts run once, while an assignment criteria script runs once for every policy. User claim scripts can also reduce Gateway load. Gateway can use claim values from the claims token instead of querying an external system for every new TCP stream initiated by every user. --- ## Functionality of user claim scripts The JavaScript can use existing user, device, and system claims. It runs in a sandboxed JavaScript engine that supports external httpGet/httpPost/httpPut/httpDelete calls. Keep this script as efficient as possible and ensure it executes quickly, because the sign-in process waits for it to complete. - After three seconds, a warning message is posted to the dashboard that names the offending script. - After ten seconds, the script times out. - After 15 seconds, the client fails over to the next Controller, and this process might be repeated. --- ## Default user claims For the local IdP and Connector IdP, a default list of mapped attributes appears under ***Attributes Mapped to User Claims***. For LDAP providers, a list of AD-mapped attributes is included. You can edit or delete included attributes. If you delete a claim that is used as criteria in a policy or condition, the expression always returns *False*. ### ![Attributes mapped to user claims including ID, username, and contact information.](https://cdn.us.document360.io/e7482ce5-acfa-4c3b-b76c-b6c32472644a/Images/Documentation/default_attributes.png?sv=2026-02-06&spr=https&st=2026-11-21T21%3A39%3A40Z&se=2026-11-21T22%3A39%3A40Z&sr=b&sp=r&sig=Hdul77we0R8VWFgo6Tyi7p2xyigCy%2F7OaLzQwgmnKMk%3D) #### LDAP groups Use the `groups match` operator to check for membership in an LDAP group. This operator requires an exact match. If you test the LDAP `groups` claim with the `contains` operator, you must provide the full FQDN of the group name, for example: CN=group3,OU=sweden,DC=myzone,DC=com", "CN=group4,OU=sweden,DC=myzone,DC=com For security reasons, we do not recommend partial matches, but you can do them in JavaScript. For example, you can flatten the `groups` claim to a single string: `var all_groups = claims.users.groups.toString()` and then check for a group name: `var match= all_group.indexOf('CN=Developers,') > -1;` > [!NOTE] > **NOTE** > > Including the trailing comma for security reasons prevents unintentional matches such as `CN=Developers Inactive, OU=` versus `CN=Developers, OU=..` #### Mapping to array-based user attributes AppGate ZTNA can map a single claim name to an attribute with multiple values (multiple lines). The Controller generates multiple instances of that user claim. Each instance is populated by the next value in the array order. For example, if the array attribute `otherHomePhone` is mapped to claim name `Phone`, a user who has two other phone numbers will have a claims token containing two instances of the `Phone` claim. For details about the default user claim attribute mapping, refer to [Claims in detail](/v1/docs/claims-in-detail-v7-0).