使用SharePointOnlineCredentials对SharePoint Online进行远程服务器身份验证

时间:2013-12-01 00:07:34

标签: .net authentication sharepoint dll office365

我正尝试从远程Windows服务器以编程方式向我的SharePoint Online 2013(如Office 365)站点进行身份验证。我尝试了各种方法,但最有希望的是使用“客户端对象模型”SharePointOnlineCredentials。它在我的开发PC上工作正常,但在部署到我的服务器时失败(“FileNotFoundException:msoidcliL.dll”)。

  • 我正在使用这种方法: http://www.vrdmn.com/2013/01/authenticating-net-client-object-model.html
  • 在我的开发PC上,我安装了SharePoint 2013客户端对象模型 来自的组件 http://www.microsoft.com/en-us/download/details.aspx?id=35585;哪一个 在我的电脑上正常工作
  • 在Visual Studio中,我引用了 Microsoft.SharePoint.Client.dll和 Microsoft.SharePoint.Client.Runtime.dll(C:\ Program Files \ Common Files \ microsoft shared \ Web Server Extensions \ 15 \ Client)
  • 在Visual Studio中,我无法为msoidcliL.dll添加引用(甚至 虽然它在我的电脑上的“C:\ Program Files \ Common Files \ microsoft”中 共享\ Web Server Extensions \ 15 \ ISAPI“文件夹)。
  • 我有3个文件 这些文件位于服务器上的bin文件夹中:msoidcliL.dll, Microsoft.SharePoint.Client.dll,和 Microsoft.SharePoint.Client.Runtime.dll
  • 我的服务器是共享/虚拟服务器,未安装SharePoint。

如何让SharePointOnlineCredentials在我的服务器上运行?

我的c#代码:

    protected void Page_Load(object sender, EventArgs e)
    {
        using (ClientContext clientContext = new ClientContext("https://mysite.sharepoint.com/"))
        {
            SecureString passWord = new SecureString();
            foreach (char c in "mypassword".ToCharArray()) passWord.AppendChar(c);
            clientContext.Credentials = new SharePointOnlineCredentials("myusername@mysite.onmicrosoft.com", passWord);
            Web web = clientContext.Web;
            clientContext.Load(web);
            clientContext.ExecuteQuery();
            Lbl1.Text = web.Title;
        }
    }

0 个答案:

没有答案
相关问题