Sharepoint Onlineをvb.netプログラムと完全にリンクしているので、助言があれば助けになるでしょう。VB.netを使用してSharepoint Onlineのユーザーを認証する
私は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 "[email protected]".ToCharArray()
password.AppendChar(c)
Next
ClientContext.Credentials = New SharePointOnlineCredentials("[email protected]", 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()
でヒットするエラーが
An exception of type 'System.Net.WebException' occurred in Microsoft.SharePoint.Client.dll but was not handled in user code
Additional information: The remote server returned an error: (403) Forbidden.
です認証の問題が原因であることを理解していますSharepoint urlは、法人の許可されたユーザーを対象としています。コード内の資格情報が許可されたユーザーに属していると仮定します。
コーディングが間違っているか、企業のITセキュリティポリシーに起因している可能性がありますか?
こんにちは@グルパラン、ご返信ありがとうございます。いいえ、それはまだ私に403エラーを与える。 –
@TanStanleyあなたはサイトのURLを正しく置き換えていますか? https://sample.sharepoint.com –
テスト目的のために私はClientContextを新しいClientContext( "https://sample.sharepoint.com")として使用しています。しかし、私はWebアプリケーションからの応答を得ることができる前にエラーが発生します。 –