<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic .NET SDK: AsDirectConnection returns 'Authentication failed.' in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/NET-SDK-AsDirectConnection-returns-Authentication-failed/m-p/1602368#M10972</link>
    <description>&lt;P&gt;I'm trying to connect to our Qlik Sense server via the .NET SDK. To retrieve the list of apps and sheets.&lt;/P&gt;&lt;P&gt;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."&lt;/P&gt;&lt;P&gt;I exported a certificate from QMC and installed the client and root certificate on my Windows machine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the following code to create the location:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What causes this exception and how to fix this?&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 05:16:41 GMT</pubDate>
    <dc:creator>mtukker</dc:creator>
    <dc:date>2024-11-16T05:16:41Z</dc:date>
    <item>
      <title>.NET SDK: AsDirectConnection returns 'Authentication failed.'</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/NET-SDK-AsDirectConnection-returns-Authentication-failed/m-p/1602368#M10972</link>
      <description>&lt;P&gt;I'm trying to connect to our Qlik Sense server via the .NET SDK. To retrieve the list of apps and sheets.&lt;/P&gt;&lt;P&gt;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."&lt;/P&gt;&lt;P&gt;I exported a certificate from QMC and installed the client and root certificate on my Windows machine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the following code to create the location:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What causes this exception and how to fix this?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 05:16:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/NET-SDK-AsDirectConnection-returns-Authentication-failed/m-p/1602368#M10972</guid>
      <dc:creator>mtukker</dc:creator>
      <dc:date>2024-11-16T05:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: .NET SDK: AsDirectConnection returns 'Authentication failed.'</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/NET-SDK-AsDirectConnection-returns-Authentication-failed/m-p/1606870#M11043</link>
      <description>&lt;P&gt;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 &lt;A href="https://my.uri:4747" target="_blank"&gt;https://my.uri:4747&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;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):&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;var ccertificateCollection = CertificateManager.LoadCertificateFromDirectory(@"c:\cert", certificatePWD);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense-developer/April2019/APIs/net+sdk/html/M_Qlik_Engine_Communication_CertificateManager_LoadCertificateFromDirectory.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense-developer/April2019/APIs/net+sdk/html/M_Qlik_Engine_Communication_CertificateManager_LoadCertificateFromDirectory.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 08:15:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/NET-SDK-AsDirectConnection-returns-Authentication-failed/m-p/1606870#M11043</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2019-07-29T08:15:49Z</dc:date>
    </item>
  </channel>
</rss>

