【发布时间】:2017-03-28 01:54:09
【问题描述】:
我对将 Sharepoint Online 与 vb.net 程序链接完全不熟悉,任何建议肯定会有所帮助。
我添加了 2 个 .dll 文件的参考,Microsoft.Sharepoint.Client 和 Microsoft.Sharepoint.Client.Runtime。它们是从链接SharePoint Server 2013 Client Components SDK 下载的。
下面是我的代码,
Imports Microsoft.SharePoint.Client
Imports Microsoft.SharePoint
Imports Microsoft
Imports System.Net
Imports System.Security
Public Class FilesRetrievalFromSharePoint
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Using ClientContext As New ClientContext("https://sample.sharepoint.com/Home.aspx")
Dim password As New System.Security.SecureString()
For Each c As Char In "pw@12345".ToCharArray()
password.AppendChar(c)
Next
ClientContext.Credentials = New SharePointOnlineCredentials("user1@sample.com", password)
Dim web As Web = ClientContext.Web
ClientContext.Load(web)
ClientContext.ExecuteQuery()
End Using
End Sub
以及下面的其他几个类End Sub
Private Class SharePointOnlineCredentials
Implements ICredentials
Private password As SecureString
Private v As String
Public Sub New(v As String, password As SecureString)
Me.v = v
Me.password = password
End Sub
Public Function GetCredential(uri As Uri, authType As String) As NetworkCredential Implements ICredentials.GetCredential
Throw New NotImplementedException()
End Function
End Class
我将在ExecuteQuery() 遇到的错误是
Microsoft.SharePoint.Client.dll 中出现“System.Net.WebException”类型的异常,但未在用户代码中处理
附加信息:远程服务器返回错误:(403) Forbidden。
我了解这是由于身份验证问题,并且 Sharepoint 网址是为公司中的授权用户设计的。假设代码中的凭据属于授权用户。
是由于编码错误还是由于公司 IT 安全政策?
【问题讨论】:
标签: vb.net authentication sharepoint