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:
- public void CreateFolderStructures(MigrationFolders migrationFolders)
- {
- using (ClientContext clientContext = new ClientContext("Site URL")
- {
- string SPOnlineUsername = "Username";
- string SPOnlinePassword = "PASSWORD";
- foreach (char c in SPOnlinePassword)
- {
- securePassword.AppendChar(c);
- }
- clientContext.Credentials = new SharePointOnlineCredentials(SPOnlineUsername, securePassword);
- var list = clientContext.Web.Lists.GetByTitle(DocumentLibraryName);
- ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
- newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
- newItemInfo.LeafName = migrationFolders.FolderName;
- newItemInfo.FolderUrl = "SITEURL" + migrationFolders.FolderPath;
- ListItem newListItem = list.AddItem(newItemInfo);
- newListItem.Update();
- list.Update();
- clientContext.ExecuteQuery();
-
- newListItem["Modified"] = migrationFolders.ModifiedDDate;
- newListItem["Created"] = migrationFolders.CreatedDate;
- newListItem.Update();
- list.Update();
- clientContext.ExecuteQuery();
- }
- }
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?