ITokenDataExtension.SetUserToken(Byte[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定 SharePoint 使用者令牌。 此方法由報告伺服器用來將 SharePoint 使用者憑證傳送至資料處理擴充套件。
public:
void SetUserToken(cli::array <System::Byte> ^ UserToken);
public void SetUserToken(byte[] UserToken);
abstract member SetUserToken : byte[] -> unit
Public Sub SetUserToken (UserToken As Byte())
參數
- UserToken
- Byte[]
其中的陣列 byte 代表代幣資料。
範例
以下程式碼示範如何建立一個連接類別,實作IDbConnection一個介面,該介面能透過 SharePoint 使用者憑證連接到 SharePoint 資料來源。
using System.Microsoft.ReportingServices.DataProcessing;
using Microsoft.SharePoint;
public class SPConnection : ITokenDataExtension, IDbConnection
{
private SPUserToken token = null;
private SPSite site = null;
...
// Implement the SetUserToken method in ITokenDataExtension
public void SetUserToken(byte[] UserToken)
{
token = new SPUserToken(UserToken);
}
// Implement the Open method in IDbConnection
public void Open()
{
// Connect to a site collection using the token.
// To use a variable for site URL, implement the
// IDbConnection.ConnectionString property accordingly.
site = new SPSite(
"http://contoso/sites/salesdata/thisyear/default.aspx",
token);
...
}
//Implement the other methods and properties in IDbConnection
...
}
Imports System.Microsoft.ReportingServices.DataProcessing
Imports Microsoft.SharePoint
Public Class SPConnection
Implements ITokenDataExtension
Implements IDbConnection
Private token As SPUserToken = Nothing
Private site As SPSite = Nothing
... ' Implement the SetUserToken method in ITokenDataExtension
Public Sub SetUserToken(ByVal UserToken As Byte())
token = New SPUserToken(UserToken)
End Sub
' Implement the Open method in IDbConnection
Public Sub Open()
' Connect to a site collection using the token.
' To use a variable for site URL, implement the
' IDbConnection.ConnectionString property accordingly.
site = New SPSite(_
"http://contoso/sites/salesdata/thisyear/default.aspx",_
token)
End Sub
'Implement the other methods and properties in IDbConnection
...
End Class
備註
使用者憑證幾乎總是登入的使用者。 在訂閱交付的情況下,這是訂閱創建者的代幣。 若報告伺服器無法取得使用者令牌,則會建立無人值守執行帳號的 SharePoint 令牌。 欲了解更多資訊,請參閱配置無人值守執行帳號(SSRS 設定管理員)。