3

We have a console application running every night which updates some project plans with CSOM. This uses the SharePointOnlineCredentials for authentication.

But the IT departments wants to change the flag of LegacyAuthProtocolsEnabled of the tenant to false. This has as consequence that SharePointOnlineCredentials can no longer be used as you can read here.

A suggested approach in the link above was to use a ClientId and ClientSecret. I've tested this with the PnP Core AutheticationManager function GetAppOnlyAuthenticatedContext. This works for a ClientContext object for SharePoint Online but it does not work after modifying this function to return a ProjectContext object. A ProjectServerError "GeneralNotLicensed" is thrown because the SharePoint Principal does not have a Project Online license (see here).

My third attempt was to use the Office365ClaimsHelper class found here. This contacts https://login.microsoftonline.com/extSTS.srf for a SAML token by providing the username and password. Now this approach works for a demo environment, but not for the production environment. I suspect because this has a Multi-Factor authentication.

To put things short: does anyone have an idea on how to get a ProjectContext object without using SharePointOnlineCredentials and without showing a pop-up to log in a user on a Multi-Factor authentication environment?

0

If SAML approach works for you, then I think you can simply generate an app password for your user with MFA and use that password instead of a real user password.
So in your case, you will use username and app password as your authentication data.

Read this article to find out how to create a new app password (section To create another app password).

  • The option to create an app password seems to be missing. I also cannot change the mobile phone nr that a text message is sent to when connecting from a network outside of the company. Changing my password is also not possible: Your organization doesn’t allow you to change your password on this site. Please change your password according to the method recommended by your organization, or ask your admin if you need help. – nvandeputte Jan 18 at 12:28
  • Office 365 admin should enable app passwords first, then it will be available. – Sergei Sergeev Jan 18 at 12:45
  • Ok, IT is looking into it as we speak. In the meantime, do you see another option then requesting a SAML token? I've found different options that work for SharePoint Online (SharePoint app-only and Azure AD app-only) but both don't work for Project Online. Surely, Microsoft must have provided a way to connect with Project Online with flag LegacyAuthProtocolsEnabled set to false without having a pop-up to log in the user? – nvandeputte Jan 22 at 12:20
  • To my knowledge, there is no other way to do that with Project Online, because you know, that in Project every operation is user related (with separate permissions etc.). It simply doesn't have "app-only" option like in SharePoint. – Sergei Sergeev Jan 22 at 12:23
-1

Managed to find a working solution thanks to following PowerShell script: https://blogs.technet.microsoft.com/sharepointdevelopersupport/2018/02/07/sharepoint-online-active-authentication/

Translated this to C# code and calls to Project Online CSOM work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.