.net 使用SharePointOnline凭据对SharePoint Online进行远程服务器身份验证

.net 使用SharePointOnline凭据对SharePoint Online进行远程服务器身份验证,.net,authentication,sharepoint,dll,office365,.net,Authentication,Sharepoint,Dll,Office365,我正在尝试通过编程方式从远程Windows服务器验证SharePoint Online 2013(如Office 365)网站。我尝试过各种方法,但最有希望的是使用“客户端对象模型”SharePointOnlineCredentials。它在我的开发PC上运行良好,但在部署到服务器时失败(“FileNotFoundException:msoidcliL.dll”) 我使用的方法是: 在我的开发PC上,我安装了SharePoint 2013客户端对象模型 来自 ; 哪一个 在我的电脑上工作很好

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

  • 我使用的方法是:
  • 在我的开发PC上,我安装了SharePoint 2013客户端对象模型 来自 ; 哪一个 在我的电脑上工作很好
  • 在VisualStudio中,我引用了 Microsoft.SharePoint.Client.dll和 Microsoft.SharePoint.Client.Runtime.dll(C:\Program Files\Common 文件\microsoft共享\Web服务器扩展\15\Client)
  • 在Visual Studio中,我无法添加msoidcliL.dll的引用(甚至 虽然它在我的电脑上的“C:\Program Files\Common Files\microsoft 共享\Web服务器扩展\15\ISAPI“文件夹)
  • 我有全部3个文件 在服务器上“我的bin”文件夹中的以下文件中:msoidcliL.dll, Microsoft.SharePoint.Client.dll,以及 Microsoft.SharePoint.Client.Runtime.dll
  • 我的服务器是共享/虚拟服务器,未安装SharePoint
如何获取SharePointOnline凭据以在服务器上工作

我的c#代码:


我刚刚看了一个关于您的问题的演示,您应该看看Peter Holpar()的博客,因为他想尽快发布代码。他正在使用Windows 8应用程序使用SharePointOnline凭据。此处描述了问题的可能原因:--对注册表中硬编码的ClentUtility SetupDirectory的引用。我不知道如何在共享服务器上编辑注册表,因此无法在那里安装客户端组件SDK。
    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;
        }
    }