Recently I run into a problem where NAV service did shut down every time I did add or delete a user.
The event log explain the problem like bellow. So it obvious that we of some reason can’t connect to the database.Type: System.Data.SqlClient.SqlExceptionClass: 14LineNumber: 1Number: 916State: 1Source: .Net SqlClient Data ProviderErrorCode: -2146232060Message: The server principal "XX\YY" is not able to access the database "ZZ" under the current security context.
When looking at the security for database “ZZ” I found the same problem as the event log was pointing at, no trace of user “XX\YY” with gives the NAV service access to the database. It turns out that when adding or deleting a NAV user all user privileges is re-synced, and any user not part of the new list is deleted. And if the NAV service account is not part of the user list, NAV service can’t longer connect to database.
The solution is very simple. You have to make sure that the service account is added as a user in NAV under Tools - Security - Windows Logins. Followed by syncing logins.