Skip to main content Skip to complementary content
Close announcements banner

Step 2 - Accessing

After Qlik Sense has been located and a location object has been fetched, the next step is to set up the security mode for the communication. This can be done in various ways, depending on whether it is Qlik Sense Desktop or Qlik Sense Server. If the security mode is not established, the access to the location object will be refused.

Information noteSee the API reference for more information about the methods.

Accessing Qlik Sense Desktop

For Qlik Sense Desktop, the method to use in order to set up the security mode is method AsDirectConnectionToPersonalEdition. This means that the location is defined as a direct connection to Qlik Sense Personal (Desktop).

Example: Set up security mode to Qlik Sense Desktop

       private static ILocation ConnectToDesktop()
       {
		var location = Qlik.Engine.Location.FromUri(new Uri("ws://127.0.0.1:4848"));
		location.AsDirectConnectionToPersonalEdition();

		return location;
	 }

Accessing Qlik Sense Server

Qlik Sense Server can be used either with a proxy (QPS) or without. If running http this needs to be stated in the method calls, parameter proxyUsesSsl is default set to true and can be omitted in the method call.

Information noteMake sure you server configuration is set up correct according to the SDK, See Step 1 - Locating

Qlik Sense Server with proxy

Information noteIf using virtual proxy, parameter VirtualProxyPath has to be set on the Qlik.Engine.Location object.

By default, NTLM (NT Lan Manager) authentication is used to connect to a Qlik Sense Server installation. If no specific settings are applied, method AsNtlmUserViaProxy is called to set up the security mode for Qlik Sense Server with proxy.

Example:  

	private static ILocation ConnectToServerThroughProxy()
	{	
		var location = Qlik.Engine.Location.FromUri(new Uri("https://<machine>"));
		location.AsNtlmUserViaProxy(proxyUsesSsl:true);
			
		// If using virtual proxy, the VirtualProxyPath must be set, e.g. https://<machine>/path/to/virtual/proxy
		location.VirtualProxyPath = "path/to/virtual/proxy";
	
		return location;
	}	

Static header

The security mode can also be set up to send user information in the static header. This can be of interest when authentication of the user is done by the client code, and the users still want to operate in separate contexts. The method to use for this is AsStaticHeaderUserViaProxy. When using static header you can still use SSL by setting proxyUsesSsl to true. The AuthenticationHeaderName is by default X-Qlik-User, see QMC how to configure AuthenticationHeaderName. This setting should only be used when you can restrict who are allowed to send users to the proxy.

Example:  

	private static ILocation ConnectToServerThroughProxyWithUser(string userId)
	{                           
		var location = Qlik.Engine.Location.FromUri(new Uri("https://<machine>"));
		location.AsStaticHeaderUserViaProxy(userId, headerAuthenticationHeaderName = null, proxyUsesSsl:true);
			
		// If using virtual proxy, the VirtualProxyPath must be set, e.g. https://<machine>/path/to/virtual/proxy
		location.VirtualProxyPath = "path/to/virtual/proxy";

		return location;
	}
		

Qlik Sense Server without proxy

If you not want to use the proxy for authentication, the security mode can be setup as a direct connection to Qlik Sense using a specific user. This is achieved with method AsDirectConnection. If extendedSecurityEnvironment is enabled, this needs to be stated in the method call. By default, this is set to false and can be omitted in the method call. Certificates are needed in order to communicate with the server directly. If running on local computer (trying to connect to server from the server machine), the certificates should already be in place, but if you are trying to connect to remote server, the certificates must be exported.

Example:  

	private static ILocation ConnectToServerWithoutProxy(string userDirectory, string userId)
	{	
		var location = Qlik.Engine.Location.FromUri(new Uri("https://<machine>:4747"));
		location.AsDirectConnection(userDirectory, userId, extendedSecurityEnvironment:false);

		return location;
	}	

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!