Carl
Carl

Reputation: 61

Bypass MFA for App-Only authentication with Project Online (CSOM): Encountering 'User Not Found in Active Directory or Project DB' Error

Issue

We are attempting to access Project Online data in Project Permission mode using app-only authentication, specifically to bypass MFA for programmatic access, as we aim for continuous, automated access without any user-interaction. We are using CSOM, using Microsoft.ProjectServer.Client.ProjectContext in .NET 4.8 to connect to Project Online. Despite following several documented approaches with client certificates, client secrets, and OAuth configurations, we keep encountering errors like 401 Unauthorized and User not found in Active Directory or in project db. Below is a summary of our steps. Despite multiple attempts, we consistently receive errors blocking access. We have followed recommended documentation for client credentials, certificates, and permissions but still face access issues.

Technology

Solutions Attempted

public static void Login(this ProjectContext context)
{
    var clientId = "xxx";
    var clientSecret = "xxx";
    var authority = "https://login.microsoftonline.com/xxx";
    var scope = "https://xxx.sharepoint.com/.default";
    var certificate = new X509Certificate2("c:\\temp\\cert.pfx", "xx");
    
    var app = ConfidentialClientApplicationBuilder.Create(clientId)
        .WithCertificate(certificate)
        .WithAuthority(new Uri(authority))
        .Build();

    AuthenticationResult result = TaskHelper.BlockingAwait(() => app.AcquireTokenForClient(new[] { scope }).ExecuteAsync());
    string accessToken = result.AccessToken;
    context.ExecutingWebRequest += (sender, e) =>
    {
        e.WebRequestExecutor.RequestHeaders["Authorization"] = "Bearer " + accessToken;
    };
}

Key Questions:

  1. Is there a method for app-only authentication in Project Online in Project Permission mode__ that bypasses MFA for automated access?

  2. Has anyone succeeded in applying app-only credentials for Project Online access__, specifically in Project Permission mode?

  3. Are there any alternative permission configurations__ (like Azure AD settings, conditional access policies, or app permissions) that could facilitate this access?

Thank you in advance!

Edit: Sorry for the bad formatting.

Upvotes: 0

Views: 64

Answers (0)

Related Questions