🔍 Code Extractor

class ObjectSharingInformationUser

Maturity: 46

A class representing information about a principal (user or group) with whom a SharePoint securable object is shared, providing access to their email, SIP address, login name, and related principal/user objects.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/object_sharing_information_user.py
Lines:
9 - 41
Complexity:
moderate

Purpose

This class serves as a data model for SharePoint object sharing information, encapsulating details about users or groups that have access to shared resources. It extends the Entity base class and provides convenient property accessors for principal information such as email, SIP address, and login name, as well as methods to retrieve associated Principal and User objects. This is typically used when querying or managing sharing permissions on SharePoint objects.

Source Code

class ObjectSharingInformationUser(Entity):
    """Contains information about a principal with whom a securable object is shared. It can be a user or a group."""

    @property
    def email(self):
        # type: () -> Optional[str]
        """Specifies the email address for the user."""
        return self.properties.get("Email", None)

    @property
    def sip_address(self):
        # type: () -> Optional[str]
        """Specifies the SIP address of the user."""
        return self.properties.get("SipAddress", None)

    @property
    def login_name(self):
        # type: () -> Optional[str]
        """Specifies the login name for the principal."""
        return self.properties.get("LoginName", None)

    def principal(self):
        """The principal with whom a securable object is shared. It is either a user or a group."""
        return self.properties.get(
            "Principal",
            Principal(self.context, ResourcePath("Principal", self.resource_path)),
        )

    def user(self):
        """Specifies the user with whom a securable object is shared."""
        return self.properties.get(
            "User", User(self.context, ResourcePath("User", self.resource_path))
        )

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The client context object that manages the connection to SharePoint and handles API requests. Inherited from Entity base class.

resource_path: The ResourcePath object representing the location of this entity in the SharePoint API hierarchy. Inherited from Entity base class.

Return Value

Instantiation returns an ObjectSharingInformationUser instance that provides access to sharing information properties. The email, sip_address, and login_name properties return Optional[str] values (None if not set). The principal() method returns a Principal object, and the user() method returns a User object, both lazily loaded from the properties dictionary or created with appropriate resource paths.

Class Interface

Methods

@property email(self) -> Optional[str] property

Purpose: Returns the email address of the user with whom the object is shared

Returns: Optional string containing the user's email address, or None if not available

@property sip_address(self) -> Optional[str] property

Purpose: Returns the SIP (Session Initiation Protocol) address of the user, typically used for instant messaging and communication

Returns: Optional string containing the user's SIP address, or None if not available

@property login_name(self) -> Optional[str] property

Purpose: Returns the login name (username) of the principal with whom the object is shared

Returns: Optional string containing the principal's login name, or None if not available

principal(self) -> Principal

Purpose: Retrieves or creates the Principal object representing the user or group with whom the securable object is shared

Returns: A Principal object either retrieved from cached properties or newly created with the appropriate resource path

user(self) -> User

Purpose: Retrieves or creates the User object representing the specific user with whom the securable object is shared

Returns: A User object either retrieved from cached properties or newly created with the appropriate resource path

Attributes

Name Type Description Scope
properties dict Dictionary storing the entity's properties including Email, SipAddress, LoginName, Principal, and User. Inherited from Entity base class. instance
context ClientContext The SharePoint client context used for API communication. Inherited from Entity base class. instance
resource_path ResourcePath The resource path identifying this entity's location in the SharePoint API hierarchy. Inherited from Entity base class. instance

Dependencies

  • typing
  • office365.runtime.paths.resource_path
  • office365.sharepoint.entity
  • office365.sharepoint.principal.principal
  • office365.sharepoint.principal.users.user

Required Imports

from typing import Optional
from office365.runtime.paths.resource_path import ResourcePath
from office365.sharepoint.entity import Entity
from office365.sharepoint.principal.principal import Principal
from office365.sharepoint.principal.users.user import User

Usage Example

from office365.sharepoint.sharing.objectSharingInformationUser import ObjectSharingInformationUser
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.user_credential import UserCredential

# Establish SharePoint connection
ctx = ClientContext('https://contoso.sharepoint.com/sites/team')
ctx.with_credentials(UserCredential('user@contoso.com', 'password'))

# Typically obtained from sharing information query
sharing_info_user = ctx.web.get_file_by_server_relative_url('/sites/team/doc.docx').get_sharing_information().execute_query()

# Access user properties
for user_info in sharing_info_user.users:
    email = user_info.email
    login_name = user_info.login_name
    sip_address = user_info.sip_address
    print(f'User: {login_name}, Email: {email}')
    
    # Get associated principal or user object
    principal = user_info.principal()
    user = user_info.user()

Best Practices

  • This class is typically not instantiated directly by users but is returned as part of SharePoint sharing information queries
  • Properties are lazily loaded from the internal properties dictionary, so ensure the object has been populated via execute_query() before accessing properties
  • The principal() and user() methods return objects that may require additional API calls to load their full data
  • Check for None values when accessing email, sip_address, or login_name properties as they may not always be populated
  • This class inherits from Entity, so it has access to the context and resource_path for making additional SharePoint API calls
  • The properties dictionary is the source of truth for all data; methods like principal() and user() create new objects if not already cached in properties

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ObjectSharingInformation 80.4% similar

    A class that provides comprehensive information about the sharing state of SharePoint securable objects (documents, list items, sites), including permissions, sharing links, and user access details.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/object_sharing_information.py
  • class SharingPermissionInformation 74.3% similar

    A class representing sharing permission information for SharePoint entities such as groups or roles, providing access to permission metadata and default permission status.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/permission_information.py
  • class SharedWithUser 72.1% similar

    A data class representing a user with whom content has been shared, capturing their email and name for change log tracking in sharing actions.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/shared_with_user.py
  • class PickerEntityInformation 71.5% similar

    A class representing additional information about a principal (user, group, or security entity) in SharePoint's people picker system.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/ui/applicationpages/peoplepicker/entity_information.py
  • class User_v1 71.2% similar

    Represents a user in Microsoft SharePoint Foundation, extending the Principal class to provide user-specific operations and properties.

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