远程服务器返回错误:(401)未授权使用winform中的sharepoint [英] The remote server returned an error: (401) unauthorized using sharepoint in winform

查看:360
本文介绍了远程服务器返回错误:(401)未授权使用winform中的sharepoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.





我尝试过:





What I have tried:

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);
      }
    }
}

推荐答案

也许是一种类型,但passwor应该是密码。至......

无报价。
perhaps a type but "passwor" should be password.To....
No quotes.


这篇关于远程服务器返回错误:(401)未授权使用winform中的sharepoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆