首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >表表未过期的可信票证-包括ClientIP

表表未过期的可信票证-包括ClientIP
EN

Stack Overflow用户
提问于 2017-07-07 14:48:45
回答 1查看 3.2K关注 0票数 1

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

已经实现了Tableau可信身份验证,以便从tableau服务器获取受信任的票证。一旦检索到票证,我将把票证附加到仪表板URL以及每个菜单的服务器名。

可信的票务模块运行良好,可视化在我的web应用程序中呈现。但是,我经常收到“无法找到未过期票证”错误的消息。

在检查此错误时,这是由于票证调用被重复所致。

我接触到了这方面的支持,并得到了一个回应,我可以添加client_ip在我的信任票务。

塔布洛可信票

我无法找到任何与在可信票务中添加client_ip相关的代码文章。

下面是我信任的票证代码。

代码语言:javascript
复制
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中嵌入视图的问题。

下面的代码可能会帮助有相同问题的用户。

代码语言:javascript
复制
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";
            }
        }
EN

回答 1

Stack Overflow用户

发布于 2017-07-25 08:25:57

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

代码语言:javascript
复制
postData = postData +"&client_ip=" +<variable for client IP>;

在tableau服务器上处理它的方式是:

  1. 在Tableau服务器上打开wgserver.extended_trusted_ip_checking。详见此处
  2. Tableau将匹配在POST请求‘client_ip=XXX.XXX’中传递的客户端IP,同时获取令牌,与浏览器试图访问tableau服务器的机器的实际IP相匹配。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44973748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档