我有一个ASP.NET web应用程序,在该应用程序中,我根据用户单击的菜单呈现与站点不同的桌面仪表板。我有多个菜单,每个菜单都绑定到一个tableau URL。
已经实现了Tableau可信身份验证,以便从tableau服务器获取受信任的票证。一旦检索到票证,我将把票证附加到仪表板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将被更改为每个用户,这将如何处理在可信的票务?
更新
我使用tableau提供的源代码解决了如何在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";
}
}发布于 2017-07-25 08:25:57
假设您的代码工作正常,(我在Java中完成了这个部分,而实际上不是asp.net方面的专家),您所要做的就是添加如下内容:
postData = postData +"&client_ip=" +<variable for client IP>;在tableau服务器上处理它的方式是:
https://stackoverflow.com/questions/44973748
复制相似问题