How to Fetch User and Group Assignments Across Unity Catalog Workspaces in Databricks

🔐 How to Fetch User and Group Assignments Across Unity Catalog Workspaces in Databricks

📌 Introduction

As organizations move toward centralized data governance with Databricks Unity Catalog (UC), understanding user and group access across multiple workspaces becomes critical for:

  • Access audits
  • Compliance reporting
  • Cross-team collaboration tracking

But here’s a common misconception:

“If I fetch group and user assignments from a Unity Catalog–enabled workspace, I’ll get info for all workspaces using the same UC.”

❌ Wrong!
Even with Unity Catalog, workspace group assignments are scoped to each workspace individually unless you query using account-level APIs.

This blog explains why this happens, and shows you how to properly fetch group-user mappings across workspaces — both at the workspace level and the account level.


🧠 Understanding the Scope

ComponentScopeAPI to Use
Unity Catalog (catalogs/schemas)Account-levelGET /accounts/<account_id>/groups
Group-to-user assignmentsWorkspace-levelGET /api/2.0/preview/scim/v2/Groups
Workspace access (entitlements)Workspace-levelGET /api/2.0/workspace/<id>/permissions

🚧 Common Mistake

You run a group listing query on a Unity Catalog–enabled workspace, expecting it to show group-user relationships for all other workspaces linked to the same UC.

Result: You’ll only get group membership for that specific workspace — not across all.


✅ Solution 1: Fetch User-Group Mapping via Workspace SCIM API

Use this method if you only care about one specific workspace.

Python Notebook Example:

# Setup
workspace_url = "https://<workspace>.cloud.databricks.com"
token = "Bearer <your-token>"

# Get Groups
resp = requests.get(f"{workspace_url}/api/2.0/preview/scim/v2/Groups", headers={"Authorization": token})
groups = resp.json()["Resources"]

# Loop through groups and print users
for group in groups:
    print(f"Group: {group['displayName']}")
    for member in group.get("members", []):
        user_id = member["value"]
        # Fetch user details
        user = requests.get(f"{workspace_url}/api/2.0/preview/scim/v2/Users/{user_id}", headers={"Authorization": token})
        print(user.json().get("userName", "Unknown"))

✅ Solution 2: Use Unity Catalog Account-Level APIs

Use this method if you want full visibility across all UC-enabled workspaces:

Step-by-step:

  1. Generate Account-Level Token
  2. Use Account SCIM APIs:
GET /api/2.0/accounts/<account_id>/groups
GET /api/2.0/accounts/<account_id>/users
  1. Use Workspace Listing API to enumerate which groups are assigned to each workspace:
GET /api/2.0/accounts/<account_id>/workspaces
  1. Correlate mappings to build a full picture of which group has access to which workspace or catalog.

🧪 Bonus: Cross-Workspace Group Audit Script

Need a script to list all workspaces and users assigned per group?

We can loop like this:

# Pseudo code
for workspace in all_workspaces:
    call /scim/v2/Groups on each workspace
    collect group-user info
combine all into one CSV or Delta table

Let me know if you’d like the full working version of this!


📎 Summary

Use CaseScopeAPI Required
Audit Unity Catalog access across workspaces✅ Account-wideAccount-level SCIM + UC Permissions APIs
Check group membership in a workspace🚫 Local to workspaceSCIM API /Groups in that workspace only
Global group access visibility✅ Cross-workspaceRequires cross-querying or account token

🎯 Summary

Use CaseAPI EndpointToken Scope
Get global UC group-user mappingshttps://accounts.databricks.com/api/...🔐 Account-level PAT
Get group-user assignments per workspacehttps://<workspace-url>/api/2.0/preview/scim/...🔐 Workspace PAT
Get catalog/schema/table access privilegesUnity Catalog permissions APIs🔐 Account-level PAT

🔚 Final Thoughts

With Unity Catalog, data governance is centralized — but identity management is still workspace-scoped unless accessed via account APIs.

For full visibility across your enterprise data platform, make sure to:

  • Use account-level tokens
  • Query account-wide group and user APIs
  • Document and consolidate group-user relationships regularly

Related Posts

Z-ORDER in Databricks: Magic or Myth?

When it helps, when it hurts, how to pick columns, and what KPIs to measure. Introduction: Why the Hype Around Z-ORDER? If you’ve spent time in Databricks,…

Read More

Taming Small Files in Delta Lake

Optimal file sizes, compaction strategies, and how to keep your Delta tables lightning-fast Why Small Files Are a Big Problem Delta Lake is powerful, but it inherits…

Read More

Databrick Serverless compute plane networking

Here’s a simple line-by-line summary of the Serverless compute plane networking (08/04/2025): General idea Serverless egress control (outbound connections) Network Connectivity Configuration (NCC) What NCC enables: Extra…

Read More

Databrick Serverless compute limitations

Here’s a simple, line-by-line summary of the Serverless compute limitations (09/29/2025): General limitations Streaming limitations Machine learning limitations Notebook limitations Job limitations Compute-specific limitations Caching limitations Hive…

Read More

Best practices for Databrick serverless compute

Best practices for serverless compute Big picture Before you migrate Ingesting data (getting data in) Querying external data (without moving it) Spark configurations Watch your costs Quick…

Read More

Databrick Serverless compute release

Here’s a simple line-by-line summary of the important points from the Serverless Compute release notes (09/24/2025): Perfect 👍 Here’s a one-page cheat sheet table for the Serverless…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x