class UserDirectoryInfo
A data class representing user information retrieved from a directory service, such as Active Directory or Azure AD, used in SharePoint sharing operations.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/user_directory_info.py
4 - 22
simple
Purpose
This class encapsulates user directory information for SharePoint sharing scenarios. It inherits from ClientValue, making it serializable for communication with SharePoint services. The class stores various user identifiers including name, NetId, primary email, and principal name, which are commonly used in enterprise directory services for user identification and authentication. It's primarily used when querying or sharing content with users from an organization's directory service.
Source Code
class UserDirectoryInfo(ClientValue):
"""User information from directory service."""
def __init__(self, name=None, net_id=None, primary_email=None, principal_name=None):
"""
:param str name: Principal name of the directory user. E.g. user@domain.com.
:param str net_id: User NetId property in directory.
:param str primary_email: User primary email of the directory user. E.g. user@domain.com.
:param str principal_name: Principal name of the directory user. E.g. user@domain.com.
"""
super(UserDirectoryInfo, self).__init__()
self.Name = name
self.NetId = net_id
self.PrimaryEmail = primary_email
self.PrincipalName = principal_name
@property
def entity_type_name(self):
return "SP.Sharing.UserDirectoryInfo"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
name: The principal name of the directory user, typically in the format 'user@domain.com'. This is an optional string parameter that defaults to None if not provided.
net_id: The NetId property of the user from the directory service. This is a directory-specific identifier that may vary based on the organization's directory configuration. Optional string parameter defaulting to None.
primary_email: The primary email address of the directory user, typically in the format 'user@domain.com'. This is the main email contact for the user. Optional string parameter defaulting to None.
principal_name: The principal name of the directory user in the format 'user@domain.com'. This is typically the User Principal Name (UPN) used for authentication. Optional string parameter defaulting to None.
Return Value
Instantiation returns a UserDirectoryInfo object with the specified user directory attributes. The entity_type_name property returns the string 'SP.Sharing.UserDirectoryInfo', which identifies this object type in SharePoint's client object model.
Class Interface
Methods
__init__(self, name=None, net_id=None, primary_email=None, principal_name=None)
Purpose: Initializes a UserDirectoryInfo instance with user directory information
Parameters:
name: Principal name of the directory user (e.g., user@domain.com)net_id: User NetId property from directory serviceprimary_email: Primary email address of the directory user (e.g., user@domain.com)principal_name: Principal name of the directory user (e.g., user@domain.com)
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the SharePoint entity type name for this object, used in client object model serialization
Returns: String 'SP.Sharing.UserDirectoryInfo' identifying this object type in SharePoint's type system
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Name |
str or None | Principal name of the directory user, typically in format user@domain.com | instance |
NetId |
str or None | User NetId property from the directory service, a directory-specific identifier | instance |
PrimaryEmail |
str or None | Primary email address of the directory user, typically in format user@domain.com | instance |
PrincipalName |
str or None | Principal name (UPN) of the directory user, typically in format user@domain.com | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.sharing.user_directory_info import UserDirectoryInfo
# Create a user directory info object with all parameters
user_info = UserDirectoryInfo(
name='john.doe@contoso.com',
net_id='johndoe',
primary_email='john.doe@contoso.com',
principal_name='john.doe@contoso.com'
)
# Access attributes
print(user_info.Name) # 'john.doe@contoso.com'
print(user_info.NetId) # 'johndoe'
print(user_info.PrimaryEmail) # 'john.doe@contoso.com'
print(user_info.PrincipalName) # 'john.doe@contoso.com'
# Get entity type name for SharePoint operations
print(user_info.entity_type_name) # 'SP.Sharing.UserDirectoryInfo'
# Create with partial information
user_info_minimal = UserDirectoryInfo(primary_email='jane.smith@contoso.com')
print(user_info_minimal.PrimaryEmail) # 'jane.smith@contoso.com'
print(user_info_minimal.Name) # None
Best Practices
- This is a data transfer object (DTO) with no complex logic, primarily used for passing user information between client and SharePoint services.
- All constructor parameters are optional, allowing flexible instantiation based on available user information.
- The class is immutable after instantiation in typical usage - attributes are set during construction and read thereafter.
- When using with SharePoint sharing operations, ensure at least one identifier (name, primary_email, or principal_name) is provided for proper user resolution.
- The entity_type_name property should not be modified as it's used by the SharePoint client object model for serialization.
- This class inherits from ClientValue, which provides serialization capabilities for SharePoint REST API communication.
- Attribute names use PascalCase (Name, NetId, PrimaryEmail, PrincipalName) to match SharePoint's naming conventions.
- When integrating with SharePoint sharing APIs, this object is typically populated from directory service queries or used to specify target users for sharing operations.
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class User_v2 70.5% similar
-
class ObjectSharingInformationUser 69.9% similar
-
class UserIdInfo 69.6% similar
-
class MembersInfo 69.2% similar
-
class SharingUtility 68.6% similar