Identity attributes in Unity Catalog ABAC policies (Beta)

Important

Identity attributes in ABAC policies are in Beta. To use them, an account admin must turn on the Identity Attributes in ABAC Policies preview from the account console Previews page. See Manage account-level previews.

What are identity attributes?

Identity attributes are properties of a user, such as their department or country. Each attribute has a name and a value. For example, a user's department can be hr and their country can be germany.

Use them in row filter and column mask policies to control access based on who runs the query, without creating separate groups for every combination of user properties. For example, you can mask employee addresses for everyone outside hr, or filter sales transactions by the user's country and division.

Identity attributes are synced from Microsoft Entra ID. The following attributes are available: department, division, organization, costCenter, title, userType, locality, region, and country.

Identity attribute functions

Identity attributes can have multiple values. For example, a user's region attribute can contain both EMEA and US.

Use the following functions to evaluate identity attributes in a policy's WHEN clause or in its filtering or masking UDF:

Function Use it in Returns
has_identity_attribute_value('attribute_key', 'value') WHEN clause true if the user has the specified value for the given attribute key. If the user has no value for the attribute, it returns false.
has_identity_attribute_tag_match('attribute_key', 'tag_key') WHEN clause true if the user has a value for the given attribute key that matches the value of the governed tag with key tag_key, set directly or inherited from the schema or catalog. If the user has no value, it returns false.
user_identity_attribute_values(session_user(), 'attribute_key') UDF ARRAY<STRING> containing all values of the user's attribute. If the attribute has no values for the user, the array is empty.

To mask data for everyone outside hr, including users without a department value, use WHEN NOT has_identity_attribute_value('department', 'hr'). See Row filter and column mask policy evaluation and runtime behavior.

user_identity_attribute_values only supports returning the attribute values of the user running the statement (session user), so its first argument must be session_user(). See Authorized user and session user. To use this function in a policy UDF, the querying users need serverless compute or Databricks Runtime 19 and above. Queries from other compute types throw an error.

Attribute names and values are case-sensitive. For example, finance and Finance don't match.

Policy examples

The following examples show how to use these functions in a policy. For the full steps, see Create a policy with identity attributes:

  • Mask employee addresses for everyone outside hr. In the WHEN clause of the column mask policy: WHEN NOT has_identity_attribute_value('department', 'hr')
  • Filter sales transactions based on the country of the querying user. In the row filter UDF: RETURN array_contains(user_identity_attribute_values(session_user(), 'country'), row_country);
  • Mask columns unless the user's department owns the table. In the WHEN clause of the column mask policy: WHEN NOT has_identity_attribute_tag_match('department', 'owning_department')

Configure attribute syncing from Microsoft Entra ID

An account admin can configure attribute syncing from Microsoft Entra ID through the mechanism that you already use for identity management: automatic identity management or System for Cross-domain Identity Management (SCIM) provisioning. To check which mechanism your account uses, click Security in the account console and open the Identity provider setup tab.

Automatic identity management

Automatic identity management is enabled by default for accounts created after August 1, 2025.

With automatic identity management, you choose which attributes to sync with the Identity Attribute Control List preview. A user's attributes are updated within about five minutes after the user signs in.

  1. Turn on the Identity Attribute Control List preview:
    1. As an account admin, log in to the account console.
    2. In the sidebar, click Previews.
    3. Turn on Identity Attribute Control List.
  2. Select the attributes to sync:
    1. In the sidebar, click Security.
    2. Click the Identity provider setup tab.
    3. In the Identity management section, under Configure identity attributes, click Manage attributes.
    4. Select the attributes that you want to use, such as Department and Country, and click Save.
  3. Confirm that the attributes synced:
    1. In a separate tab, log out and log back in to the workspace. Attributes are refreshed on login.
    2. In the account console sidebar, click User management.
    3. On the Users tab, find your own user.
    4. Click the Identity attributes tab. Attributes without a value show an en dash (–).

SCIM

Sync identity attributes with automatic identity management. To sync them through SCIM instead, contact your account team.

Create a policy with identity attributes

The following steps show how to create a row filter policy and a column mask policy with identity attributes. With the row filter policy, users see only the rows where the country column matches their own country, in every table in the prod.sales schema with a column tagged country_column. With the column mask policy, everyone outside the hr department sees **** in columns tagged pii with the value address.

Before you start, confirm with an account admin that identity attributes have been configured. See Configure attribute syncing from Microsoft Entra ID.

Row filter

  1. Create a UDF that uses the user_identity_attribute_values function to check whether the row's country matches any of the user's country identity attribute values. Users without a value for this attribute can't access any rows:

    CREATE FUNCTION prod.governance.is_users_country(row_country STRING)
    RETURNS BOOLEAN
    RETURN array_contains(
      user_identity_attribute_values(session_user(), 'country'),
      row_country
    );
    
  2. Tag the country column and create a row filter policy. The policy uses the country_column tag to identify which columns to pass to the UDF:

    ALTER TABLE prod.sales.orders
      ALTER COLUMN country SET TAGS ('country_column' = '');
    
    CREATE POLICY orders_by_country
    ON SCHEMA prod.sales
    ROW FILTER prod.governance.is_users_country
    TO `account users` EXCEPT `sales_admins`
    FOR TABLES
    MATCH COLUMNS has_tag('country_column') AS country_col
    USING COLUMNS (country_col);
    

    You can also create the policy in Catalog Explorer or with the REST API. See Create and manage row filter and column mask policies.

  3. Test the policy. Query prod.sales.orders. You see only the orders for your own country. Members of sales_admins still see all rows, because the group is in the policy's EXCEPT clause.

Column mask

  1. Create the masking UDF. This example masks a whole column.

    CREATE FUNCTION prod.governance.mask_value(val STRING)
    RETURNS STRING
    RETURN '****';
    
  2. Tag the column and create the policy. Add the condition on the user's attribute to the policy's WHEN clause. The mask applies unless the user's department is hr:

    ALTER TABLE prod.hr.employees
      ALTER COLUMN home_address SET TAGS ('pii' = 'address');
    
    CREATE POLICY mask_addresses_outside_hr
    ON SCHEMA prod.hr
    COLUMN MASK prod.governance.mask_value
    TO `account users`
    FOR TABLES
    WHEN NOT has_identity_attribute_value('department', 'hr')
    MATCH COLUMNS has_tag_value('pii', 'address') AS address_col
    ON COLUMN address_col;
    
  3. Test the policy. Query prod.hr.employees. If your department is hr, you see the home addresses. Otherwise, you see ****.

Use identity attributes to prevent group and policy explosion

When access depends on multiple user properties, such as department, country, or division, group-based access control can quickly become difficult to manage. You may need a separate group for every combination of values, along with hardcoded group checks in UDFs or separate policies. As new values are added, the number of groups and the effort to maintain access rules grow.

Identity attributes let you use user properties already available in Microsoft Entra ID directly in access rules, without the need to represent every combination through groups.

The following examples show how this simplifies row filters and column masks.

Row filtering example

Suppose users should see only the rows in prod.sales.orders for their own division and country, and there are 5 divisions and 10 countries.

If you encode this through one group for each combination of division and country, you end up with 50 groups, and you need to hardcode all of them in the UDF through is_account_group_member(). This setup is cumbersome to create and maintain: when a country or division is added, you need new groups and new checks in the UDF.

-- With groups: one group and one check for each division x country combination
CREATE FUNCTION prod.governance.filter_orders(row_division STRING, row_country STRING)
RETURNS BOOLEAN
RETURN
     (is_account_group_member('retail_france')    AND row_division = 'retail'    AND row_country = 'france')
  OR (is_account_group_member('retail_germany')   AND row_division = 'retail'    AND row_country = 'germany')
  OR (is_account_group_member('wholesale_france') AND row_division = 'wholesale' AND row_country = 'france')
  -- ... 47 more checks, one for each remaining division and country group

With identity attributes you can write a single policy with a simple UDF that doesn't need to be changed when new countries or divisions are added.

-- With identity attributes: one check that covers all values for division and country
CREATE FUNCTION prod.governance.filter_orders(row_division STRING, row_country STRING)
RETURNS BOOLEAN
RETURN array_contains(user_identity_attribute_values(session_user(), 'division'), row_division)
   AND array_contains(user_identity_attribute_values(session_user(), 'country'), row_country);

Column masking example

Suppose everyone can query the tables in the prod catalog, but columns tagged confidential should be visible only to users in the department that owns the table, and there are 8 departments. Each table has a governed tag owning_department.

If you encode this through groups, you need 8 policies, one for each department, that masks the confidential columns for everyone outside that department's group. When a department is added, you need a new group and a new policy.

-- With groups: one group and one policy for each department
CREATE POLICY mask_confidential_finance
ON CATALOG prod
COLUMN MASK prod.governance.mask_value
TO `account users` EXCEPT `finance`                  -- The finance group is exempt from the mask...
FOR TABLES
WHEN has_tag_value('owning_department', 'finance')   -- ...for the tables that they own
MATCH COLUMNS has_tag('confidential') AS confidential_col
ON COLUMN confidential_col;

-- Repeated 7 more times, each with another department in both EXCEPT and WHEN

With identity attributes you can express this in a single policy that compares the table's owning_department tag with the user's department. The policy doesn't need to be changed when new departments are added.

-- With identity attributes: one policy for every department
CREATE POLICY mask_confidential_outside_owning_department
ON CATALOG prod
COLUMN MASK prod.governance.mask_value
TO `account users`
FOR TABLES
WHEN NOT has_identity_attribute_tag_match('department', 'owning_department')
MATCH COLUMNS has_tag('confidential') AS confidential_col
ON COLUMN confidential_col;

Limitations

  • has_identity_attribute_value and has_identity_attribute_tag_match are not supported in GRANT or DENY policies.
  • Identity attributes are available on users only, not on service principals or groups.

Important

Don't store sensitive information in identity attributes. Their values can be read through the account APIs.

Additional resources