Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
michasiuk
Contributor III
Contributor III

QlikNprinting-CLI PowerShell module Connect-NPrinting gives unauthorised response

@Marc

I'm using the QlikNprinting-CLI PowerShell module but when I run the Connect-Nprinting Command:

Connect-NPrinting -AuthScheme ntlm -Computer NprintingServerName -TrustAllCerts

I get this error:

WARNING: From: https://NprintingServerName:4993/api/v1/login/ntlm
Response: Unauthorized

I then tried using the following code to connect which I have gotten to work on another server.

 

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #Set the security protocol

add-type @"

using System.Net;

using System.Security.Cryptography.X509Certificates;

public class TrustAllCertsPolicy : ICertificatePolicy {

public bool CheckValidationResult(

ServicePoint srvPoint, X509Certificate certificate,

WebRequest request, int certificateProblem) {

return true;

}

}

"@

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy #Set the trust Policy

#Set up the connections to Nprinting Api interface and logon to Nprinting

$url = "https://$($NprintingFQDN):4993/api/v1/login/ntlm"
$s = Invoke-RestMethod -UseDefaultCredentials -Uri $url -Method Get -SessionVariable websession

But this time I get the following error:

Invoke-RestMethod : {"result":null,"code":1,"message":null}
At line:2 char:6
+ $s = Invoke-RestMethod -UseDefaultCredentials -Uri $url -Method Get - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Not fully sure what I should be looking for to fix these errors or what would be causing them. 

Labels (1)
11 Replies
michasiuk
Contributor III
Contributor III
Author

This code has worked on other machines in the past. It's just that we undergone a server replacement and the PowerShell  is not working on the new serve The Qlik-CLI works but the QlikNprinting-CLI is causing me issues this time for some reason.

michasiuk
Contributor III
Contributor III
Author

Before I forget the script is running under the same service account that the Qlik Nprinting Services are running under.

Marc
Employee
Employee

For windows integrated authentication (ntlm) to work, the Domain Account needs to be configured against a User in NPrinting.  If it is not, then NPrinting does not know which of its users the request is coming from.

As you can see in the screen shot below. 
On the Left the domain account is unpopulated and I get the same error you have.

On the right it is populated correctly and it works.

Marc_0-1700537793617.png

 

michasiuk
Contributor III
Contributor III
Author

@Marc

I already know about this and I have done this the development and preprod instances of Nprinting that I have and everything works fine there. The problem is that the production instance of Nprinting is giving me errors still even though I have defined the service account as a super user on the instance in the same way as the other two instances. Trying to figure what is different between the instances.

michasiuk
Contributor III
Contributor III
Author

michasiuk_0-1700540019309.jpeg

 

michasiuk
Contributor III
Contributor III
Author

Trying to figure out what I should be looking for.

 

Marc
Employee
Employee

The Domain Account specified does not conform to Domain\Username 
from the look of it, you may be missing the backslash between the domain and Username.

but you will notice, that under your domain account, it says "Not NT Domain User...." 

Marc_1-1700540427134.png

it should show "Valid NT Domain User"

Marc_0-1700540326048.png

 

michasiuk
Contributor III
Contributor III
Author

Apologies typo situation where I couldn't see my nose despite my face been looking at it for too long.

@Marc 

Ruggero_Piccoli
Support
Support

Note for all readers: QlikNprinting-CLI PowerShell module is not an official QlikTech product. We do not supply official support on it.

Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.