diff --git a/Cargo.toml b/Cargo.toml index 422e84f..6b2b3ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 " diff --git a/src/auth.rs b/src/auth.rs index 36f1f57..ca79e6c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -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 { + 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 @@ -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 { + self.app.check_user_exists(username).await + } + /// Initiate an MFA flow for enrollment via user credentials. /// /// # Arguments