Windows Challenge/Response (NTLM
) is the authentication protocol used on networks that include systems running the Windows operating system and on stand-alone systems. I was able to handle NTLM
authentication using org.apache.http.client.HttpClient
version 4.4
.
Here is the Maven dependency I have used (Methods and method names can be slightly different in other versions).
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
</dependency>
Following imports are required for the implementation. This is the basic requirement for a non-SSL connection.
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.NTCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
Here is the implementation. Need to replace Username
, Password
, and Domain
with real credentials.
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
HttpClient httpClient = HttpClientBuilder.create()
.setDefaultCredentialsProvider(credentialsProvider)
.build();
credentialsProvider.setCredentials(AuthScope.ANY, new NTCredentials("Username", "Password", null, "Domain"));
Now this http client can be used to communicate with the Dynamics NAV API.
But I was unable to find a free testing environment for Microsoft Dynamics NAV within my region (Asia). But few cloud service providers are offering free testing trials for other regions.
As a Linux user I had to install Windows in a virtual environment and install Dynamics NAV on it to create a testing environment. If you are familiar with Docker you can download the Dynamics NAV Docker image from this link.