2

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.

Any suggestion how to resolve this error?

Note: I tried by declaring clientcontext globally in the program but still no luck.

  • are you using the correct DLLs ? For SPO, you need to use the SharePoint Online CSOM dlls with version 16. Do try with the latest from nuget – Gautam Sheth Apr 5 '18 at 6:02
  • Let me check that too. – Aakash Maurya Apr 5 '18 at 6:08
  • The nuget package name is Microsoft.SharePointOnline.CSOM and the latest version is 16.1.7521.1200. You should be using that to connect to your SharePoint Online site – Gautam Sheth Apr 5 '18 at 6:11
  • Same issue. One folder created successfully. After that error starts "The sign-in name or password does not match one in the Microsoft account system. – Aakash Maurya Apr 5 '18 at 6:13
  • are you using external user account or a Microsoft account ? These accounts wont work. You need to use the work account (not personal account) to connect to SPO. Also, check if you are using myuser@tenantname.sharepoint.com instead of myuser@tenantname.onmicrosoft.com – Gautam Sheth Apr 5 '18 at 6:18

Your Answer

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

Browse other questions tagged or ask your own question.