1 Reply Latest reply on May 30, 2016 5:37 AM by Tamas Foldi

    trusted tickets

    Chandra Shekar komirishetty

      i want to enable trusted tickets to access dashboards directly from webserver without auth. however i am testing using PHP code but i am getting invalid user error msg for the below php code.

      when i checked the log in the data\tabsvc\logs\vizqlserver\vizql-0.txt, I am seeing below error and i am unable to proceed further. please advise. i have tried sending with and without domain username also with capital and small cases still it has failed.

       

      2016-05-25 07:32:21.648 -0700 (Default,,-,V0W3dcCoD8gAAAw8MDkAAAFy) catalina-exec-4 : ERROR wgsessionId= com.tableausoftware.model.workgroup.service.TrustedTicketServiceImpl - Invalid user: ksoftglobal/kcs

       

       

       

       

      <p>An embedded view appears below:</p>

       

       

      <?php

       

       

      // This user-provided library should define get_user(), which returns the

      // name of the user currently logged into this application.

      //

      //include 'auth.php';

       

       

      // Tableau-provided functions for doing trusted authentication

      //$remote_addr = $_SERVER['REMOTE+ADDR']; 

      $server = 'tabserver:8080';

      $username = 'kcs';

      $clientIp = '';

       

       

      // To get a PNG

      $url = 'views/Ckng_Dashboards/Customerwisebusiness?format=png';

      $contentType = 'image/png';

       

       

      // To get a PDF you could use:

      // $url = 'views/foo/bar?format=pdf';

      // $contentType = 'application/pdf';

       

       

      // Request the trusted ticket ID by sending username & client_ip via POST fields to "/trusted"

      $params = compact('username');

       

       

      if ($clientIp) {

          $params['client_ip'] = $clientIp;

      }

       

       

      $ch = curl_init();

      curl_setopt_array($ch, array(

          CURLOPT_URL            => "http://{$server}/trusted",

          CURLOPT_POST           => true,

          CURLOPT_POSTFIELDS     => $params,

          CURLOPT_RETURNTRANSFER => true,

      ));

       

       

      $ticket = (int) curl_exec($ch);

      echo $ticket;

      curl_close($ch);

       

       

      // Valid ticket IDs are positive integers

      if ($ticket <= 0) {

          throw new Exception("Server did not return a valid ticket.");

      }

      // At this point we have a valid trusted ticket ID, so let's request the content

      $url = ltrim(trim($url), '/');

      $fullUrl = "http://{$server}/trusted/{$ticket}/{$url}";

      $ch = curl_init();

      curl_setopt_array($ch, array(

          CURLOPT_URL            => $fullUrl,

          // Tell cURL to follow the redirect from Tableau Server

          CURLOPT_FOLLOWLOCATION => true,

          // Enable cookies so that cURL handles the session ID cookie, but don't load any existing

          // cookies from a file (since we don't have any)

          CURLOPT_COOKIEFILE     => '',

          CURLOPT_FAILONERROR    => true,

          CURLOPT_HEADER         => false,

      ));

      // Simply output the content to the browser

      header("Content-Type: {$contentType}");

      curl_exec($ch);

      curl_close($ch);

       

       

      ?>

       

       

      <p>

      This was created using trusted authentication.

      </p>