Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I did a small development where it is necessary to connect to a SharePoint list, the development works well with my user, but when testing with another user who has the same privileges on the site, it sends the following error message

"The sign-in name or password does not match one in the Microsoft Account System."

I already tried with other users that the site are owners, but I get the same result. Can you help me see what is the error in the above?

What I have tried:

This is my code
VB.NET
Imports Microsoft.SharePoint.Client
Imports Microsoft.SharePoint
Imports System.Security
Imports System.Net

Public Class Form4

    Dim siteUrl As String = "https://example.sharepoint.com/site/SiteExample/"
    Dim context As New ClientContext(siteUrl)
    Dim web As Web

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try

            Dim userNameSP As String = TextBox1.Text
            Dim password As String = TextBox2.Text
            Dim secureString As SecureString = New NetworkCredential("", password).SecurePassword

            Dim cred = New SharePointOnlineCredentials(userNameSP, secureString)
            Dim clientContext As New ClientContext(siteUrl)
            clientContext.Credentials = cred
            Dim web As Web = clientContext.Web
            Dim oWebsite As Web = clientContext.Web
            Dim collList As ListCollection = oWebsite.Lists

            Dim oList As List = collList.GetByTitle("Example Test")

            clientContext.Load(oList)

            clientContext.ExecuteQuery()

            Dim query As CamlQuery = CamlQuery.CreateAllItemsQuery()

            query.ViewXml = "<View Scope='RecursiveAll'><Query><ViewFields><FieldRef Name='Category/></ViewFields></Query></View>"

            Dim AllItems As ListItemCollection = oList.GetItems(query)
            clientContext.Load(AllItems)
            clientContext.ExecuteQuery()

            If AllItems.Count > 0 Then

                ... Do Something

            end if

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class

Any idea?

Thank you in advance.
Posted
Updated 8-Dec-20 21:57pm
v2
Comments
[no name] 8-Dec-20 22:58pm    
There are owners / "admins" and "users"; and admins add users / visitors. I don't think you're aware of the distinction.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900