Aakash Maurya

Aakash Maurya

  • 135
  • 14.3k
  • 293.8k

The sign-in name or password does not match one...

Apr 3 2018 5:04 AM

I am creating a C# Solution that will migrate the documents from SharePoint 2010 On-Premises to SharePoint Online.

I am done with the program. But when I run the program it runs successfully for few times. After some time it starts throwing error:

Microsoft.SharePoint.Client.IdcrlException: The sign-in name or password does not match one in the Microsoft account system.

I am unable to track the actual error.

Here I am sharing my code:

  1. public void CreateFolderStructures(MigrationFolders migrationFolders)  
  2. {  
  3.     using (ClientContext clientContext = new ClientContext("Site URL")  
  4.     {  
  5.         string SPOnlineUsername = "Username";  
  6.         string SPOnlinePassword = "PASSWORD";  
  7.         foreach (char c in SPOnlinePassword)  
  8.         {  
  9.             securePassword.AppendChar(c);  
  10.         }  
  11.         clientContext.Credentials = new SharePointOnlineCredentials(SPOnlineUsername, securePassword);  
  12.         var list = clientContext.Web.Lists.GetByTitle(DocumentLibraryName);  
  13.         ListItemCreationInformation newItemInfo = new ListItemCreationInformation();  
  14.         newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;  
  15.         newItemInfo.LeafName = migrationFolders.FolderName;  
  16.         newItemInfo.FolderUrl = "SITEURL" + migrationFolders.FolderPath;  
  17.         ListItem newListItem = list.AddItem(newItemInfo);  
  18.         newListItem.Update();  
  19.         list.Update();  
  20.         clientContext.ExecuteQuery();  
  21.   
  22.         newListItem["Modified"] = migrationFolders.ModifiedDDate;  
  23.         newListItem["Created"] = migrationFolders.CreatedDate;  
  24.         newListItem.Update();  
  25.         list.Update();  
  26.         clientContext.ExecuteQuery();  
  27.    }  
  28. }  

The above code is called in foreach loop.

I have gone through following URL but that is not the case with me.

  • http://sharepointconnoisseur.blogspot.in/2015/09/how-to-resolve-error.html
  • http://kb.cloudiway.com/sharepoint-the-sign-in-name-or-password-does-not-match-one-in-the-microsoft-account-system/
  • https://knowledge-junction.com/2017/12/24/office-365-connecting-to-sharepoint-online-site-using-csom-when-multi-factor-authentication-mfa-is-enabled-for-the-user/

Any suggestion how to resolve this error?


Answers (13)