Member 13043998 Ответов: 1

Удаленный сервер вернул ошибку: (401) несанкционированное использование sharepoint в winform


I am getting the Exception:

    WebException was unhandled:
    An unhandled exception of type 'System.Net.WebException' occurred in 
    Microsoft.SharePoint.Client.dll

   Additional information: The remote server returned an error: (401) 
 Unauthorized.
However, I can access the site using the same credentials in the browser. Please note that I am using username "username@companyname.com" and my username also includes a dot in it. I am afraid whether something is wrong with my username but I can access my site using the exactly same username. Any help will be highly appreciated. Thanks in advance.


Что я уже пробовал:

I am trying to read files from Sharepoint. I have used the following codes:

using System;
using Microsoft.SharePoint.Client;
using System.Security;

  namespace VLCPlayer
{
public partial class Form1 : System.Windows.Forms.Form
{
    public Form1()
    {
        InitializeComponent();
        string url = "https://share.philips.com/sites/STS020170405131503/";
        ClientContext ctx = new ClientContext(url);
        var password = new SecureString();
        foreach (var c in "passwor".ToCharArray()) 
        { password.AppendChar(c); }
        ctx.Credentials =
           new SharePointOnlineCredentials(username, password);

        Microsoft.SharePoint.Client.Web web = ctx.Web;

        ctx.Load(web);

        ctx.ExecuteQuery();

        Console.WriteLine(web.Title);
      }
    }
}

1 Ответов

Рейтинг:
0

theoldfool

возможно, тип, но "passwor" должен быть password.To....
Никаких цитат.