Area: Product
Sub-Area: Ownership Management
Applies to: OSS + Cloud
Issue
After you delete a user, some assets can still list that user as an owner. This can confuse other users and skew ownership reporting.
You Might Be Asking
- Why does a deleted user still show as an owner?
- How do I remove a deleted user as owner of an asset?
- How do I give the asset to a new owner?
- Can I suspend a user instead of deleting them?
- How do I avoid this next time?
Cause
How the user was deleted decides whether ownership entries stay.
- A soft delete is the default for
datahub delete(--soft). It sets theremovedfield of the user's status aspect to true. This hides the user in the UI, but the user is still viewable by direct link. A soft delete does not clean up references, so ownership entries that point to the user stay on the assets. Soft deletion can be undone. - A hard delete of a user (
--hard) also deletes the references to that user.
Ownership entries that stay behind are not kept on purpose as a history. You can remove them.
Solution
Remove all references to a deleted user
Run datahub delete references with the user's urn. It deletes all references to the entity without deleting the entity itself. It takes -n/--dry-run and -f/--force.
datahub delete references --urn "urn:li:corpuser:<user_id>"
See Delete Metadata for soft and hard delete.
Remove the old owner from one asset
Use the removeOwner GraphQL mutation. It takes ownerUrn and resourceUrn. ownershipTypeUrn is optional. If you leave it out, the owner is removed regardless of ownership type. The mutation returns a Boolean.
mutation {
removeOwner(
input: {
ownerUrn: "urn:li:corpuser:<user_id>",
resourceUrn: "<asset urn>"
}
)
}
Run it once for each asset.
Add a new owner
Use the addOwners mutation. Each owner needs ownerUrn and ownerEntityType (CORP_USER, CORP_GROUP, or AI_AGENT on Cloud). You can also set type or ownershipTypeUrn. For custom ownership types, use ownershipTypeUrn. See Ownership Types.
mutation {
addOwners(
input: {
owners: [{ ownerUrn: "urn:li:corpuser:<new_user_id>", ownerEntityType: CORP_USER }],
resourceUrn: "<asset urn>"
}
)
}
Suspend a user instead of deleting
Use updateUserStatus. It needs the Manage Users & Groups privilege. The status values are ACTIVE and SUSPENDED.
mutation {
updateUserStatus(urn: "urn:li:corpuser:<user_id>", status: SUSPENDED)
}
Do not use updateCorpUserProperties for this. It has no active field. It accepts only profile fields such as displayName, title and email.
Avoid the problem
- Reassign a user's assets before you delete or suspend them.
- Make a group the owner. When a group owns an asset, every member of the group counts as an owner for owner-based policies. See Groups.