When installing ENS, use the SQL authentication and not the Windows authentication to access the ENS database. This topic is applicable for ENS on-premise installation only.

Problem

In case you connect to the ENS database using the Windows authentication then you might receive the following error:

2018/11/05 19:55:40.800 EUROPA  80000005-0001-ff00-b63f-84710c7967bb    [0000000-0000000]   (35)    Error   MailNotificationService.ProviderImpl.ApiTokensDataHandler.ApiTokensAsync    User Id:[ ] Error While loading the api tokens Exception [Cannot open database "ENS" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\LOCAL SERVICE'.] StackTrace[   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)

Cause

Connecting to the ENS database using the Windows authentication might cause this issue.

Use the SQL authentication to connect to your ENS database. In the solutions steps provided, the NT AUTHORITY\LOCAL SERVICE is the name of the user account and the database role membership for the NT AUTHORITY\LOCAL SERVICE account must have the db_owner and public enabled.

To add an SQL account to the ENS database, perform the following steps:

Solution

  1. Open the SQL Server Management Studio.
  2. Navigate to Security > Logins and add NT AUTHORITY\LOCAL SERVICE.
  3. Navigate to Security > Logins > NT AUTHORITY\LOCAL SERVICE > User Mapping > .
  4. Select the ENS database and add the required permissions.