I am building an asp.net 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 = "Dynamics.is"
User.UserName = "Gunnar"
User.Password = "<password>"
NAVPunch1.Credentials = User
NAVPunch1.Url = "http://Dynamics.is:7047/DynamicsNAV/WS/" & _
"Dynamics/Codeunit/NAVPunch"[/code]
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 = "http://Dynamics.is:7047/DynamicsNAV/WS/" & _
"Dynamics/Codeunit/NAVPunch"[/code]
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.