我有一個ASP.NET Web應用程序,在該Web應用程序中,我基於用戶點擊的菜單從站點呈現不同的Tableau儀表板。我有多個菜單,每個菜單都綁定到一個tableau URL。Tableau Unexpired Trusted Ticket - 包括ClientIP
Tableau受信任的身份驗證已實現,以從Tableau Server獲取受信任的票證。一旦檢索到票證,我將票證附加到儀表板URL以及每個菜單的服務器名稱。
可信售票模塊工作正常,可視化呈現在我的web應用程序中。但是,我經常收到「找不到未到期票證」錯誤消息。
在檢查此錯誤時,這是由於票證呼叫重複。
我接觸到了這方面的支持,並得到了一個響應,我可以在我的可信售票處添加client_ip。
我無法找到相關的可信票務加入CLIENT_IP任何代碼的文章。
以下是我信賴的機票代碼。
public class TableauTicket
{
public string getTableauTicket(string tabserver, string sUsername)
{
try
{
ASCIIEncoding enc = new ASCIIEncoding();
string postData = string.Empty;
string resString = string.Empty;
postData = "username=" + sUsername + "";
// FEATURE 816 END - Custom Visualization - KV
if (postData != string.Empty)
{
byte[] data = enc.GetBytes(postData);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(tabserver + "/trusted");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
req.ContentLength = data.Length;
Stream outStream = req.GetRequestStream();
outStream.Write(data, 0, data.Length);
outStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader inStream = new StreamReader(stream: res.GetResponseStream(), encoding: enc);
resString = inStream.ReadToEnd();
inStream.Close();
return resString;
}
else
{
resString = "User not authorised";
return resString;
}
}
catch (Exception ex)
{
string resString = "User not authorised";
return resString;
string strTrailDesc = "Exception in tableau ticket - " + ex.Message;
}
}
public int Double(int i)
{
return i * 2;
}
}
任何人都可以請讓我知道如何在CLIENT_IP可以信任的售票代碼通過?
另外,客戶端IP將針對每個用戶進行更改,以及如何在可信票證中處理這些內容?
UPDATE
我已經使用畫面上如何嵌入SharePoint中的視圖中提供的源代碼解決了這個問題。
下面是可能幫助用戶遇到同樣問題的代碼。
string GetTableauTicket(string tabserver, string tabuser, ref string errMsg)
{
ASCIIEncoding enc = new ASCIIEncoding();
// the client_ip parameter isn't necessary to send in the POST unless you have
// wgserver.extended_trusted_ip_checking enabled (it's disabled by default)
string postData = "username=" + tabuser + "&client_ip=" + Page.Request.UserHostAddress;
byte[] data = enc.GetBytes(postData);
try
{
string http = _tabssl ? "https://" : "http://";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(http + tabserver + "/trusted");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
// Write the request
Stream outStream = req.GetRequestStream();
outStream.Write(data, 0, data.Length);
outStream.Close();
// Do the request to get the response
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader inStream = new StreamReader(res.GetResponseStream(), enc);
string resString = inStream.ReadToEnd();
inStream.Close();
return resString;
}
// if anything bad happens, copy the error string out and return a "-1" to indicate failure
catch (Exception ex)
{
errMsg = ex.ToString();
return "-1";
}
}
謝謝。我已經試過這個並且實施了這個解決方案。 Tableau提供了有關如何在SharePoint中嵌入視圖的示例,並且它具有完整的源代碼。它幫助我解決了我的問題。 –