Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
mtukker
Contributor
Contributor

.NET SDK: AsDirectConnection returns 'Authentication failed.'

I'm trying to connect to our Qlik Sense server via the .NET SDK. To retrieve the list of apps and sheets.

After creating the connection I'm using the location to retrieve the actual Qlik version as a test. When using the "AsNtlmUserViaProxy" function I get the correct version of Qlik, but when I'm trying to connect via the function "AsDirectConnection" I get the exception "Authentication failed."

I exported a certificate from QMC and installed the client and root certificate on my Windows machine.

 

I'm using the following code to create the location:

 

var uri = new Uri("https://***");            
ILocation location = Location.FromUri(uri);

var certificatPWD = "****";

byte[] rawData = File.ReadAllBytes(@"c:\cert\client.pfx");

var x509 = new X509Certificate2(rawData, certificatPWD, X509KeyStorageFlags.MachineKeySet);
            
var certificateCollection = new X509Certificate2Collection
{
  x509
};

location.AsDirectConnection(userDirectory: "DOMAIN", userId: "USERNAME", certificateCollection: certificateCollection);

 

  

What causes this exception and how to fix this?

Labels (3)
1 Reply
Øystein_Kolsrud
Employee
Employee

Did you add the engine port to the uri? If you do a direct connection, then you'll need the port. It's typically 4747. So something like https://my.uri:4747

By the way, with the latest versions of the SDK there is a class for doing that certificate loading you are doing. You could write something like this (you'll need to create a secure string of the password though):

var ccertificateCollection = CertificateManager.LoadCertificateFromDirectory(@"c:\cert", certificatePWD);

 https://help.qlik.com/en-US/sense-developer/April2019/APIs/net+sdk/html/M_Qlik_Engine_Communication_...