You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
graph TD
Site["Site / Web"]
List["List / Library"]
Folder["Folder"]
File["File"]
Role["User / Group + Role Definition"]
Inherit1["⬇ inherits →"]
Inherit2["⬇ inherits →"]
Inherit3["⬇ inherits →"]
Site --> Inherit1
Inherit1 --> List
List --> Inherit2
Inherit2 --> Folder
Folder --> Inherit3
Inherit3 --> File
Site -.- Role
List -.- Break1["break_inheritance()\n→ unique permissions"]
Folder -.- Break2["break_inheritance()\n→ unique permissions"]
File -.- Break3["break_inheritance()\n→ unique permissions"]
Loading
Permissions flow down by default. A user with Read on the site gets Read on
every list, folder, and file. Use break_role_inheritance() to stop the flow
at any level and assign unique permissions.
Role definitions
Role
Permission level
Typical use
Full Control
All operations
Site owners, admins
Edit
Add, edit, delete; manage lists
Power users
Contribute
Add, edit, delete own items
Team members
Read
View only
Viewers, auditors
Examples
Lifecycle
Each script operates on a --scope site|list|folder|file (folder/file go
through their list-item facet; break/reset support site/list/folder):
fromoffice365.sharepoint.client_contextimportClientContextfromoffice365.sharepoint.sharing.role_typeimportRoleTypectx=ClientContext("https://contoso.sharepoint.com/sites/team").with_client_secret(
"contoso.onmicrosoft.com", "client_id", "client_secret"
)
# Get effective permissions on a listtarget_list=ctx.web.default_document_library()
result=target_list.get_user_effective_permissions(ctx.web.current_user).execute_query()
forlevelinresult.value.permission_levels:
print(f"Permission: {level}")
# Grant a user Contributor accesstarget_list.add_role_assignment("user@contoso.com", RoleType.Contributor).execute_query()