My website using NAV Web Service

I am building an website that communicates with NAV via Web Services.  One of the issues I had to solve was the authentication between the web and the NAV Web Services.

You can ether use NTLM authentication or the current user.  If you will be using NTLM you will need code similar to this in you website.
[code htmlscript=”false” land=”vb”]Dim NAVPunch1 As New WebService.NAVPunch
Dim User As New System.Net.NetworkCredential
User.Domain = ""
User.UserName = "Gunnar"
User.Password = "<password>"
NAVPunch1.Credentials = User
NAVPunch1.Url = "" & _
This also means that you have to store the username, domain and password in you web site code. You will also need to enable NTLM authentication in your CustomSettings.xml
[code htmlscript=”false” lang=”vb”]<add key="WebServicesUseNTLMAuthentication" value="true"></add>[/code]
The other way is to use the credentials of the user running the web. In that case the code would be similar to this:
[code htmlscript=”false” lang=”vb”]NAVPunch1.UseDefaultCredentials = True
NAVPunch1.Url = "" & _
And no changes to CustomSettings.xml are required.  The authentication will be handled with IIS.  You will need to go into Internet Information Services (IIS) Manager.  Go into Application Pools and add a new application pool

Select a name that fits you web site and then go to Advanced Settings…

and update the Idendity.

Then go and select this Application Pool for the web site.

The final step is to make sure that the user you select in your code or in the application pool has access to NAV Web Services.  That is done with the standard authentication methods in Dynamics NAV.

10 Replies to “My website using NAV Web Service”

  1. Thanks a lot. I had been searching for hours before I found your above tip. Works great.

    Cheers from Danmark,

  2. Hi, great tip, however, can I ask if it is possible to get the current Windows user that is logged into the website?

    For example, my web service returns data based on the USERID in NAV, but if I set a user in the apppool it will always return data for that particular user.

    I want it to return the data dependent on the Windows user that is logged into the website, almost so IIS passes through the WIndows Account.


    1. Hi Marc

      Did you manage to find a solution for this? we are running into the same problem, and do not seem to be able to bypass this.


      1. I would think that you need to use a single user to connect to NAV. However, you can easilly pass the current user as a parameter in the Web Service and handle that userid in NAV.

        1. Thanks Gunnar. That is what I was expecting, but it would be so much easier if I could get the login directly from the website.

  3. Hi Ian,

    Not sure if it is a similar problem but I hope it helps a little:

    The site we developed used NAV2009 R2 and was an intranet site that used the “UseDefaultCredentials = true;” command described above to pass the current Windows users credentials through to NAV.

    The problem was that when using the DefaultAppPool I kept getting 403 unauthorised errors, however it worked when the site was run locally on the server. Turns out we had setup delegation from the NAV server to the SQL server (as per 3-tiers on 3 computers MSDN article) but delegation was also required to be setup so the credential could be passed from the web server where IIS was running to the middle-tier.

    Seems to work now in our test environment using Kerberos (NTLM flag is set to false).


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.