🔍 Code Extractor

class PasswordProfile

Maturity: 48

A data class representing a user's password profile in Microsoft Graph API, containing password and password change policy settings.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/users/password_profile.py
Lines:
4 - 32
Complexity:
simple

Purpose

This class encapsulates password-related configuration for a user entity in Microsoft Graph API. It stores the user's password and flags that control password change requirements at next sign-in, including multi-factor authentication requirements. This is typically used when creating or updating user accounts in Azure Active Directory/Microsoft 365 environments.

Source Code

class PasswordProfile(ClientValue):
    """Contains the password profile associated with a user. The passwordProfile property of the user entity is a
    passwordProfile object."""

    def __init__(
        self,
        password=None,
        force_change_password_next_sign_in=None,
        force_change_password_next_sign_in_with_mfa=None,
    ):
        """
        :param str password: The password for the user. This property is required when a user is created.
             It can be updated, but the user will be required to change the password on the next login.
             The password must satisfy minimum requirements as specified by the user's passwordPolicies property.
             By default, a strong password is required.
        :param bool force_change_password_next_sign_in: true if the user must change her password on the next login;
             otherwise false.
        :param bool force_change_password_next_sign_in_with_mfa: f true, at next sign-in, the user must perform a
             multi-factor authentication (MFA) before being forced to change their password. The behavior is identical
             to forceChangePasswordNextSignIn except that the user is required to first perform a multi-factor
             authentication before password change. After a password change, this property will be automatically
             reset to false. If not set, default is false.
        """
        super(PasswordProfile, self).__init__()
        self.password = password
        self.forceChangePasswordNextSignIn = force_change_password_next_sign_in
        self.forceChangePasswordNextSignInWithMfa = (
            force_change_password_next_sign_in_with_mfa
        )

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

password: The password string for the user account. Required when creating a new user. Must satisfy minimum requirements specified by the user's passwordPolicies property. By default, a strong password is required. Can be updated, but triggers a password change requirement on next login.

force_change_password_next_sign_in: Boolean flag indicating whether the user must change their password at the next login. Set to true to force password change, false otherwise. Defaults to None if not specified.

force_change_password_next_sign_in_with_mfa: Boolean flag that requires multi-factor authentication (MFA) before forcing a password change at next sign-in. When true, user must complete MFA before changing password. Automatically resets to false after password change. Defaults to None if not specified.

Return Value

Instantiation returns a PasswordProfile object that inherits from ClientValue. The object contains three instance attributes (password, forceChangePasswordNextSignIn, forceChangePasswordNextSignInWithMfa) that can be serialized for Microsoft Graph API requests.

Class Interface

Methods

__init__(password=None, force_change_password_next_sign_in=None, force_change_password_next_sign_in_with_mfa=None)

Purpose: Initializes a new PasswordProfile instance with password and password change policy settings

Parameters:

  • password: The password string for the user account (optional, but required when creating new users)
  • force_change_password_next_sign_in: Boolean flag to force password change at next sign-in (optional, defaults to None)
  • force_change_password_next_sign_in_with_mfa: Boolean flag to require MFA before forcing password change (optional, defaults to None)

Returns: A new PasswordProfile instance

Attributes

Name Type Description Scope
password str The password for the user account. Required when creating a user, can be updated but triggers password change requirement. instance
forceChangePasswordNextSignIn bool Flag indicating whether the user must change their password at the next login. instance
forceChangePasswordNextSignInWithMfa bool Flag requiring multi-factor authentication before forcing a password change at next sign-in. Automatically resets to false after password change. instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from office365.directory.users.profiles.password import PasswordProfile

# Create a password profile for a new user
password_profile = PasswordProfile(
    password="SecureP@ssw0rd123!",
    force_change_password_next_sign_in=True,
    force_change_password_next_sign_in_with_mfa=False
)

# Access the attributes
print(password_profile.password)  # SecureP@ssw0rd123!
print(password_profile.forceChangePasswordNextSignIn)  # True
print(password_profile.forceChangePasswordNextSignInWithMfa)  # False

# Typically used when creating a user
# user = User()
# user.passwordProfile = password_profile
# user.displayName = "John Doe"
# user.userPrincipalName = "john.doe@contoso.com"
# context.users.add(user)

Best Practices

  • Always provide a strong password that meets organizational password policy requirements when creating new users
  • Set force_change_password_next_sign_in to True for new users to ensure they set their own password on first login
  • Use force_change_password_next_sign_in_with_mfa for enhanced security when password changes are required
  • This class is immutable after creation - create a new instance if you need to change password profile settings
  • The password attribute should be handled securely and never logged or exposed in plain text
  • This object is typically assigned to the passwordProfile property of a User entity before creating or updating the user
  • The forceChangePasswordNextSignInWithMfa flag automatically resets to false after the user changes their password

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class PasswordCredential 70.7% similar

    A data class representing a password credential associated with an application or service principal in Microsoft Graph API, containing password metadata and validity information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/password_credential.py
  • class PasswordAuthenticationMethod 69.0% similar

    A class representing a user's password authentication method in Microsoft 365/Office 365 directory services. This class provides a secure abstraction for password management without exposing the actual password value.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/authentication/methods/password.py
  • class UserRegistrationDetails 66.6% similar

    A data class representing the authentication and security registration state of a user, including MFA, passwordless, and self-service password reset capabilities.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/authentication/methods/details.py
  • class GroupProfile 65.2% similar

    GroupProfile is a data class that represents the profile configuration for a Microsoft 365/Azure AD group, encapsulating properties like name, description, mail settings, and security settings.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/groups/profile.py
  • class AuthenticationMethod 64.0% similar

    Represents an authentication method registered to a user in Azure Active Directory, providing functionality to manage authentication credentials such as passwords, phone numbers, and FIDO2 security keys.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/authentication/methods/method.py
← Back to Browse