class UserIdentity
A data class representing user identity information in the context of Azure AD audit logs, capturing details about users who initiated or were affected by audit activities.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/users/identity.py
4 - 19
simple
Purpose
This class serves as a data container for Azure AD audit log user information. It inherits from ClientValue (likely a base class for serializable client-side values) and stores three key pieces of user identity information: display name, IP address, and user principal name. It's designed to be used when working with Azure AD audit logs to represent user identity data in a structured format that can be easily serialized and transmitted.
Source Code
class UserIdentity(ClientValue):
"""
In the context of an Azure AD audit log, this represents the user information that initiated or
was affected by an audit activity.
"""
def __init__(self, display_name=None, ip_address=None, user_principal_name=None):
"""
:param str display_name: he identity's display name. Note that this may not always be available or up-to-date.
:param str ip_address: Indicates the client IP address used by user performing the activity (audit log only).
:param str user_principal_name: The userPrincipalName attribute of the user.
"""
super(UserIdentity, self).__init__()
self.displayName = display_name
self.ipAddress = ip_address
self.userPrincipalName = user_principal_name
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
display_name: The user's display name as shown in Azure AD. This is an optional string parameter that may not always be available or current. Used for human-readable identification of the user.
ip_address: The client IP address from which the user performed the activity being logged. This is an optional string parameter specific to audit log entries and helps track the network location of user actions.
user_principal_name: The userPrincipalName attribute of the user from Azure AD, typically in the format 'user@domain.com'. This is an optional string parameter that serves as a unique identifier for the user within the Azure AD tenant.
Return Value
Instantiation returns a UserIdentity object with three instance attributes (displayName, ipAddress, userPrincipalName) set to the provided values or None if not specified. The object inherits functionality from ClientValue for serialization and client-side operations.
Class Interface
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
displayName |
str or None | The identity's display name. May not always be available or up-to-date. Used for human-readable identification. | instance |
ipAddress |
str or None | The client IP address used by the user performing the activity. Only applicable in audit log contexts. | instance |
userPrincipalName |
str or None | The userPrincipalName attribute of the user from Azure AD, typically in format 'user@domain.com'. Serves as a unique identifier. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
# Create a UserIdentity instance with all parameters
user_identity = UserIdentity(
display_name='John Doe',
ip_address='192.168.1.100',
user_principal_name='john.doe@contoso.com'
)
# Access the attributes
print(user_identity.displayName) # Output: John Doe
print(user_identity.ipAddress) # Output: 192.168.1.100
print(user_identity.userPrincipalName) # Output: john.doe@contoso.com
# Create with partial information
user_identity_partial = UserIdentity(display_name='Jane Smith')
print(user_identity_partial.displayName) # Output: Jane Smith
print(user_identity_partial.ipAddress) # Output: None
# Create empty instance
user_identity_empty = UserIdentity()
print(user_identity_empty.displayName) # Output: None
Best Practices
- This is a simple data container class - instantiate it with the available user identity information from Azure AD audit logs
- All constructor parameters are optional, so you can create instances with partial information as needed
- The class uses camelCase for attribute names (displayName, ipAddress, userPrincipalName) to match Azure AD API conventions
- Since it inherits from ClientValue, instances can be serialized for transmission to/from Azure AD services
- This class is immutable by convention - set all values during instantiation rather than modifying attributes later
- The display name may not always be current or available, so don't rely on it as a unique identifier - use userPrincipalName instead
- IP address is only relevant in audit log contexts and may be None in other scenarios
- This class is typically instantiated by the Office365 SDK when parsing audit log responses rather than manually by developers
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class AppIdentity 75.6% similar
-
class Identity 69.3% similar
-
class ObjectIdentity 69.2% similar
-
class RiskUserActivity 67.8% similar
-
class UserIdInfo 66.3% similar