class AuthenticationMethodsRoot
A container class for navigating and accessing Azure AD authentication methods resources, providing access to user registration details and authentication method statistics.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/authentication/methods/root.py
12 - 34
moderate
Purpose
This class serves as a root entity for managing Azure Active Directory authentication methods. It provides navigation properties to access user registration details and query authentication method statistics. The class inherits from Entity and is designed to work within the Office365 SDK context, allowing retrieval of information about which authentication methods users have registered (such as MFA, passwordless authentication, and self-service password reset capabilities).
Source Code
class AuthenticationMethodsRoot(Entity):
"""Container for navigation properties for Azure AD authentication methods resources."""
def users_registered_by_method(self):
"""Get the number of users registered for each authentication method."""
return_type = ClientResult(self.context, UserRegistrationMethodSummary())
qry = FunctionQuery(self, "usersRegisteredByMethod", None, return_type)
self.context.add_query(qry)
return return_type
@property
def user_registration_details(self):
"""Represents the state of a user's authentication methods, including which methods are registered and which
features the user is registered and capable of (such as multi-factor authentication, self-service password
reset, and passwordless authentication)."""
return self.properties.get(
"userRegistrationDetails",
EntityCollection(
self.context,
UserRegistrationDetails,
ResourcePath("userRegistrationDetails", self.resource_path),
),
)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
Entity base class parameters: This class inherits from Entity, which typically requires a context object for API communication and a resource path for identifying the resource location. These are passed through the parent class constructor.
Return Value
Instantiation returns an AuthenticationMethodsRoot object that provides access to authentication method resources. The users_registered_by_method() method returns a ClientResult containing a UserRegistrationMethodSummary with statistics about registered authentication methods. The user_registration_details property returns an EntityCollection of UserRegistrationDetails objects representing individual user authentication states.
Class Interface
Methods
users_registered_by_method() -> ClientResult
Purpose: Queries and returns a summary of the number of users registered for each authentication method in the Azure AD tenant
Returns: ClientResult object containing a UserRegistrationMethodSummary with statistics about authentication method registrations across all users
@property user_registration_details -> EntityCollection
property
Purpose: Provides access to detailed registration information for individual users, including which authentication methods they have registered and which features they are capable of using
Returns: EntityCollection of UserRegistrationDetails objects, each representing a user's authentication method registration state including MFA, self-service password reset, and passwordless authentication capabilities
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | Inherited from Entity base class; provides the API communication context for executing queries against Azure AD | instance |
properties |
dict | Inherited from Entity base class; stores cached property values including the userRegistrationDetails collection | instance |
resource_path |
ResourcePath | Inherited from Entity base class; identifies the API endpoint path for this authentication methods resource | instance |
Dependencies
office365
Required Imports
from office365.directory.authentication.methods.details import UserRegistrationDetails
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.reports.userregistration.method_summary import UserRegistrationMethodSummary
from office365.runtime.client_result import ClientResult
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.function import FunctionQuery
Usage Example
from office365.graph_client import GraphClient
from office365.directory.authentication.methods_root import AuthenticationMethodsRoot
# Initialize Graph client with credentials
client = GraphClient(lambda: ('username', 'password'))
# Access authentication methods root
auth_methods = client.reports.authentication_methods
# Get summary of users registered by authentication method
method_summary = auth_methods.users_registered_by_method()
client.execute_query()
print(f"Total users registered: {method_summary.value.total_user_count}")
# Access user registration details collection
user_details = auth_methods.user_registration_details
user_details.get().execute_query()
for user in user_details:
print(f"User: {user.user_principal_name}, Methods: {user.methods_registered}")
Best Practices
- Always call execute_query() on the context after invoking users_registered_by_method() to actually execute the API request
- The class should be instantiated through the Office365 Graph client context rather than directly
- Ensure proper authentication and authorization before accessing authentication methods data
- The user_registration_details property returns a lazy-loaded collection; call get() or iterate to trigger data retrieval
- Handle API rate limits and throttling when querying large numbers of user registration details
- Cache results when appropriate as authentication method data doesn't change frequently
- Verify that the authenticated user has sufficient permissions (typically requires Reports.Read.All or similar admin scope)
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class AuthenticationMethod 75.7% similar
-
class AuthenticationMethodsPolicy 69.9% similar
-
class PolicyRoot 66.6% similar
-
class Authentication 66.1% similar
-
class PasswordAuthenticationMethod 65.7% similar