SPO Tenant authientication with MFA configured account CSOM application

Shri-6058 326 Reputation points
2021-09-23T20:50:53.79+00:00

Hi I have the working tool for the UPS access and updates. Because I didnt have SharePoint administrator role, I was unable to perform actual property updates. After I received SP administrator role(with MFA - this is our company policy elivated permission should have a MFA configured), The following authCookie (last line) fails staing Miss match with the stored Microsoft account details in the system.. This is because we have MFA configured. code has to be entered. I then did PnP.Framework setup however I am not able to replace the following with the PnP MFA authentication code replacement. Will you advise?

static bool InitializeWebService()
{
try
{
string webServiceExt = "_vti_bin/userprofileservice.asmx";
string adminWebServiceUrl = string.Empty;
//append the web service (ASMX) url onto the admin web site URL
if (_profileSiteUrl.EndsWith("/"))
adminWebServiceUrl = _profileSiteUrl + webServiceExt;
else
adminWebServiceUrl = _profileSiteUrl + "/" + webServiceExt;
LogMessage("Initializing SPO web service " + adminWebServiceUrl, LogLevel.Information);
SecureString securePassword = GetSecurePassword(_sPoAuthPasword);
SharePointOnlineCredentials onlineCred = new SharePointOnlineCredentials(_sPoAuthUserName, securePassword);

            // Get the authentication cookie by passing the url of the admin web site 
            string authCookie = **onlineCred.GetAuthenticationCookie(new Uri(_profileSiteUrl));**

// Setting up the user profile web service
_userProfileService = new UPSvc.UserProfileService();

            // assign the correct url to the admin profile web service 
            _userProfileService.Url = adminWebServiceUrl;

            // Assign previously created auth container to admin profile web service 
            _userProfileService.CookieContainer = authContainer;
            // LogMessage("Finished creating service object for SPO Web Service " + adminWebServiceUrl, LogLevel.Information);
            return true;

Please let me know. Appreciate any help.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,682 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,575 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,810 questions
{count} votes

12 answers

Sort by: Most helpful
  1. Shri-6058 326 Reputation points
    2021-10-01T21:31:52.303+00:00

    Please take a look here: My account(global administrator, sharepoint administrator) processed perfectly fine. However as soon as the next user properties started updating the context.ExecuteQuery() returns the not authorized other user property update.
    137112-image.png

    Please help.

    0 comments No comments

  2. Shri-6058 326 Reputation points
    2021-10-11T19:47:33.27+00:00

    any advise on this. Please let me know if anyone on the same boat and how you handled it.

    0 comments No comments