🔍 Code Extractor

class RoleType

Maturity: 47

An enumeration class that defines SharePoint role types with integer constants representing different permission levels for users and groups.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/role_type.py
Lines:
1 - 61
Complexity:
simple

Purpose

This class serves as a constant enumeration for SharePoint role definitions, providing standardized integer values (0-8, 255) that represent different permission levels ranging from no rights (None_) to full administrative access (Administrator). It is used to specify and validate role types when managing SharePoint permissions, user access levels, and group memberships. Each role type has specific rights and capabilities documented in its docstring.

Source Code

class RoleType:
    """Specifies the types of role definitions that are available for users and groups."""

    None_ = 0
    """The role definition has no rights on the site (2)."""

    Guest = 1
    """The role definition has limited right to view pages and specific page elements.
    This role is used to give users access to a particular page, list, or item in a list, without granting rights
    to view the entire site (2). Users cannot be added explicitly to the guest role; users who are given access to
    lists or document libraries by using permissions for a specific list are added automatically to the guest role.
    he guest role cannot be customized or deleted."""

    Reader = 2
    """
    The role definition has a right to view items, personalize Web Parts, use alerts, and create a top-level site.
    A reader can only read a site (2); the reader cannot add content. When a reader creates a site (2), the reader
    becomes the site (2) owner and a member of the administrator role for the new site (2).
    This does not affect the user's role membership for any other site (2).
    Rights included are CreateSSCSite, ViewListItems, and ViewPages.
    """

    Contributor = 3
    """
    The role definition has reader rights, and a right to add items, edit items, delete items, manage list permissions,
     manage personal views, personalize Web Part Pages, and browse directories. Includes all rights in the reader role,
     and AddDelPrivateWebParts, AddListItems, BrowseDirectories, CreatePersonalGroups, DeleteListItems, EditListItems,
     ManagePersonalViews, and UpdatePersonalWebParts roles. Contributors cannot create new lists or document libraries,
     but they can add content to existing lists and document libraries.
    """

    WebDesigner = 4
    """Has Contributor rights, plus rights to cancel check-out, delete items, manage lists, add and customize pages,
    define and apply themes and borders, and link style sheets. Includes all rights in the Contributor role, plus the
    following: AddAndCustomizePages, ApplyStyleSheets, ApplyThemeAndBorder, CancelCheckout, ManageLists. WebDesigners
    can modify the structure of the site and create new lists or document libraries. The value = 4."""

    Administrator = 5
    """Has all rights from other roles, plus rights to manage roles and view usage analysis data.
    Includes all rights in the WebDesigner role, plus the following: ManageListPermissions, ManageRoles, ManageSubwebs,
    ViewUsageData. The Administrator role cannot be customized or deleted, and must always contain at least one member.
    Members of the Administrator role always have access to, or can grant themselves access to, any item in the
    Web site. The value = 5."""

    Editor = 6
    """
        The role definition has reader rights, plus rights to Review items. Inclues all rights in the Reader role, plus
        the following: ReviewListItems. Reviewers cannot create new lists and document libraries, but they can add
        comments to existing list items or documents.
        """

    Reviewer = 7
    """The role definition is a special reader role definition with restricted rights, it has a right to view
        the content of the file but cannot download the file directly. Includes all rights in the Guest role, plus
        the following: ViewPages, ViewListItems and ViewItemsRequiresOpen."""

    RestrictedReader = 8
    """"""

    System = 255
    """For SharePoint internal use only. System roles can not be deleted, nor modified."""

Parameters

Name Type Default Kind
bases - -

Parameter Details

bases: This class does not have an __init__ method and does not accept any initialization parameters. It is a static enumeration class containing only class-level integer constants.

Return Value

This class does not have methods that return values. It provides class-level integer constants that can be accessed directly (e.g., RoleType.Administrator returns 5). When used in SharePoint operations, these integer values are passed to APIs to specify role types.

Class Interface

Attributes

Name Type Description Scope
None_ int Role with no rights on the site. Value: 0 class
Guest int Limited rights to view pages and specific elements. Users are added automatically when given access to specific lists. Cannot be customized or deleted. Value: 1 class
Reader int Rights to view items, personalize Web Parts, use alerts, and create top-level sites. Includes CreateSSCSite, ViewListItems, and ViewPages rights. Value: 2 class
Contributor int Reader rights plus ability to add, edit, and delete items, manage list permissions and personal views. Cannot create new lists but can add to existing ones. Value: 3 class
WebDesigner int Contributor rights plus ability to cancel check-out, manage lists, customize pages, apply themes and styles. Can modify site structure and create new lists. Value: 4 class
Administrator int All rights from other roles plus manage roles and view usage data. Cannot be customized or deleted, must have at least one member. Always has access to all site items. Value: 5 class
Editor int Reader rights plus ability to review items. Includes ReviewListItems right. Can add comments to existing items but cannot create new lists. Value: 6 class
Reviewer int Special reader role with restricted rights. Can view content but cannot download files directly. Includes ViewPages, ViewListItems, and ViewItemsRequiresOpen. Value: 7 class
RestrictedReader int Restricted reader role type. Value: 8 class
System int For SharePoint internal use only. Cannot be deleted or modified. Value: 255 class

Usage Example

# Access role type constants
admin_role = RoleType.Administrator  # Returns 5
reader_role = RoleType.Reader  # Returns 2
guest_role = RoleType.Guest  # Returns 1

# Use in conditional logic
if user_role == RoleType.Administrator:
    print("User has full administrative rights")
elif user_role == RoleType.Contributor:
    print("User can add and edit content")

# Use in SharePoint API calls (example)
def assign_role(user_id, role_type):
    if role_type == RoleType.None_:
        print("No permissions assigned")
    elif role_type == RoleType.WebDesigner:
        print("Assigning web designer permissions")
    # API call would use the integer value
    return role_type

# Get all available role types
role_types = [
    RoleType.None_,
    RoleType.Guest,
    RoleType.Reader,
    RoleType.Contributor,
    RoleType.WebDesigner,
    RoleType.Administrator,
    RoleType.Editor,
    RoleType.Reviewer,
    RoleType.RestrictedReader,
    RoleType.System
]

Best Practices

  • Do not instantiate this class - use the class-level constants directly (e.g., RoleType.Administrator)
  • Use these constants instead of hardcoding integer values to improve code readability and maintainability
  • Note that RoleType.None_ uses an underscore suffix to avoid conflict with Python's None keyword
  • Administrator and System roles have special restrictions: they cannot be customized or deleted
  • Guest role is automatically assigned and cannot be customized or deleted
  • When checking role permissions, remember the hierarchy: Administrator (5) has all rights from lower roles
  • System role (255) is for internal SharePoint use only and should not be assigned to users
  • Consider the specific rights included with each role as documented in the docstrings when making permission decisions

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class Role 75.2% similar

    An enumeration class representing abstract roles for SharePoint sharing permissions on securable objects in document libraries.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/role.py
  • class CalendarRoleType 70.9% similar

    An enumeration-style class that defines calendar role types and permission levels for calendar sharing in a calendar management system.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/role_type.py
  • class PrincipalType 69.1% similar

    An enumeration-style class that defines constants representing different types of principals in a SharePoint or similar access control system.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/principal/type.py
  • class PageType 68.1% similar

    An enumeration class that defines constants representing different SharePoint page types as specified in the MS-WSSFO3 protocol specification.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/pages/page_type.py
  • class SiteType 65.1% similar

    A simple enumeration-like class that defines constants for SharePoint site types.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sites/site_type.py
← Back to Browse