Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Feb 23, 2021 4:11:17 AM
Mar 14, 2018 9:24:10 AM
This is an example of how to connect to Qlik Sense using Dynamic header authentication with the .NET SDK
The following must be installed to test the example provided in this article:
*It does not need to be installed on the same machine, but proper ports must be open for incoming connection on the Qlik Sense server side.
*Qlik Sense certificates need to be installed on the machine running Microsoft Visual Studio for the connection to be trusted.
Environments:
The example below is created based on the console application (.NET framework) template. Please note that the Qlik Sense .NET SDK also need to be installed. (For details, see Qlik Sense: Getting started with the .NET SDK )
using System; using Qlik.Engine; using Qlik.Engine.Communication; namespace ConnectServerNTLM { class Program { static void Main(string[] args) { var uri = new Uri("https://qlikserver1.domain.local"); if (args.Length > 0) { uri = new Uri(args[0]); } ILocation location = Qlik.Engine.Location.FromUri(uri); location.CustomUserHeaders.Add("hdr-usr", "DOMAIN\\myuser2"); location.AsNtlmUserViaProxy(); location.VirtualProxyPath = "hdr"; PrintQlikSenseVersionNumber(location); } private static void PrintQlikSenseVersionNumber(ILocation location) { try { using (IHub hub = location.Hub(noVersionCheck: true)) { Console.WriteLine(hub.ProductVersion()); } } catch (CommunicationErrorException cex) { Console.WriteLine("Can not connect to Qlik Sense instance, check that Qlik Sense is running." + Environment.NewLine + cex.Message); } catch (Exception ex) { Console.WriteLine("General error." + Environment.NewLine + ex.Message); } Console.ReadLine(); } } }
On the Qlik Sense side, a virtual proxy with dynamic header authentication needs to be configured correctly. See below an example of configuration:
AUTHENTICATION Anonymous access mode: No anonymous user Authentication method: Header authentication dynamic user directory Header authentication header name: hdr-usr Header authentication dynamic user directory: $ud\\$id