【问题标题】:Tableau Unexpired Trusted Ticket - including ClientIPTableau 未过期的可信票证 - 包括 ClientIP
【发布时间】:2017-12-11 22:15:23
【问题描述】:

我有一个 ASP.NET Web 应用程序,在该应用程序中,我根据用户单击的菜单从站点呈现不同的画面仪表板。我有多个菜单,每个菜单都绑定到一个画面 URL。

已实施 Tableau 可信身份验证以从 tableau 服务器获取可信票证。检索到票证后,我会将票证与每个菜单的服务器名称一起附加到仪表板 URL。

受信任的票务模块工作正常,可视化正在我的 Web 应用程序中呈现。但是,我经常收到“无法找到未过期的票证”错误消息。

在检查此错误时,这是​​由于工单调用重复造成的。

我就此联系了支持人员并得到了回复,我可以在我的受信任票务期间添加 client_ip。

Tableau Trusted Ticket

我找不到任何与在可信票务中添加 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";
            }
        }

【问题讨论】:

    标签: asp.net tableau-api


    【解决方案1】:

    假设您的代码可以正常工作,(我在 Java 中完成了这部分,而不是真正的 asp.net 专家)您所要做的就是添加如下内容:

    postData = postData +"&client_ip=" +<variable for client IP>;
    

    在tableau server上的处理方式是:

    1. 您在 Tableau Server 上打开 wgserver.extended_trusted_ip_checking。 see details here

    2. Tableau 将在获取令牌时将您在 POST 请求“client_ip=XXX.XXX.XXX.XXX”中传递的客户端 IP 与浏览器尝试访问 tableau 的计算机的实际 IP 进行匹配服务器。

    【讨论】:

    • 谢谢。我已经尝试过这个并实施了解决方案。 Tableau 提供了如何在 SharePoint 中嵌入视图的示例,并且具有完整的源代码。它帮助我解决了我的问题。
    猜你喜欢
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    • 2019-04-11
    相关资源
    最近更新 更多