Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #59 from himmelblau-idm/dmulder/check_user_exists
Browse files Browse the repository at this point in the history
Check user exists
  • Loading branch information
dmulder authored May 14, 2024
2 parents bd138db + d3a70d7 commit 2e540af
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "msal"
description = "Microsoft Authentication Library for Rust"
version = "0.1.22"
version = "0.1.23"
edition = "2021"
authors = [
"David Mulder <dmulder@suse.com>"
Expand Down
33 changes: 33 additions & 0 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,26 @@ impl PublicClientApplication {
}
}

/// Check if a user exists in Azure Entra ID
///
/// # Arguments
///
/// * `username` - Typically a UPN in the form of an email address.
///
/// # Returns
/// * Success: true|false
/// * Failure: An MsalError, indicating the failure.
pub async fn check_user_exists(&self, username: &str) -> Result<bool, MsalError> {
let request_id = Uuid::new_v4().to_string();
let auth_config = self
.request_auth_config_internal(vec![], &request_id, None)
.await?;
let cred_type = self
.get_cred_type(username, &auth_config, &request_id)
.await?;
Ok(cred_type.if_exists_result == 0)
}

/// Initiate an MFA flow via user credentials.
///
/// # Arguments
Expand Down Expand Up @@ -2318,6 +2338,19 @@ impl BrokerClientApplication {
self.app.acquire_token_by_device_flow(flow).await
}

/// Check if a user exists in Azure Entra ID
///
/// # Arguments
///
/// * `username` - Typically a UPN in the form of an email address.
///
/// # Returns
/// * Success: true|false
/// * Failure: An MsalError, indicating the failure.
pub async fn check_user_exists(&self, username: &str) -> Result<bool, MsalError> {
self.app.check_user_exists(username).await
}

/// Initiate an MFA flow for enrollment via user credentials.
///
/// # Arguments
Expand Down

0 comments on commit 2e540af

Please sign in to comment.