Microsoft Dynamics Nav: Web Services User Credentials

In previous posts (Adding a Record through Web Services, Retrieving a set of Records through Web Services, Using an XMLPort as a .NET DataSource) I demonstrated a simple solution for connecting to a Microsoft Dynamics Nav Web Service. In each of the examples the default user credentials were used. To connect to a Microsoft Dynamics Nav Web Service with specified user credentials you use the System.Net.NetworkCredential:
ws = new GetSetCustomers_Binding();
            
//ws.UseDefaultCredentials = true;
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("username","password","domain");
ws.UseDefaultCredentials = false;
ws.Credentials = cred;

Leave a Comment