SQL-Server login-error of SQL-Server Agent Account

database-mailsql serversql-server-agent

I have to manage a configured SQL-Server version 2005 and have setup Database Mail successfully – test mail works.

Also I've changed the agent service to a domain user with (currently) domain admin and db admin privileges.

Now I'm getting numerous login errors for this user

[298] SQL-Server error:18456 error logging on user domain\sqlagent, [SQLSTATE 28000]

when running jobs with notification. Any idea how that can happen, when the agent service can be restarted without problem?

I've searched the web extensively but the only answers I can find are related to wrong passwords.

Best Answer

The user account that is running the SQL Server agent might not have permissions to use the database mail profile you can check that with EXECUTE msdb.dbo.sysmail_help_profileaccount_sp;

But you are having some issues with the agent account security, please try the following steps.

  • Remove all extra privileges from the Agent user account (or create a new domain account) Running the SQL Server agent with domain admin privs is just terrifying.
  • Change the user for the Agent service using the SQL Server Configuration Manager. You should never change it any other way as it will set all the necessary permissions. Change the account to network service and then back again and make sure beforehand that the agent user is neither a local or domain administrator.
  • Check the mail profile on the SQLAgent settings and make sure that it's not private and that the agent user account can use it (The user account will be made sysadmin by the Configuration manager and should be able to use all accounts)