I currently have a .net console application that needs to receive an active domain account via the appConfig file to connect to the database. The application is being executed from the TaskScheduler. I cannot use the domain account to execute the task as this is a security setting (saving password).
I have the connection string in a consolidated settings file (appSettings.config) and have set the identity in the console app settings file including the username and password
My question is how can I use the task scheduler to execute the job and have the username/password in the config files?
In testing I have used the "Local Service" account and "Network Service" account and receive an a logon error from SQL Server"
Login failed for user 'DOMAIN_NAME\MACHINE_NAME$'. Reason: Could not find a login matching the name provided. [CLIENT: xxx.xxx.xx.xx (ip address of client machine)]
If I use a local account that has admin rights, the following error is returned:
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. [CLIENT: xxx.xxx.xx.xx]
NOTES:
all machines are on the same domain and have connectivity
when the task is set to run as the domain account, and the identity tag does NOT have the username/password, the task executes as designed.
appSettings.config
<?xml version="1.0"?> <appSettings> <!-- CONNECTION STRINGS --> <add key="connectionString" value="Data Source=DB_SERVER_NAME;Initial Catalog=DB_NAME;Integrated Security=SSPI;" /> ..... ..... application.exe.config
<?xml version="1.0"?> <configuration> <configSections> </configSections> <appSettings file="F:\SPASystems\Conf\appSettings.config" /> <system.web> <identity impersonate="true" userName="DOMAIN_NAME\svc.ACCOUNT_NAME.user" password="dummy_password"/> <membership defaultProvider="ClientAuthenticationMembershipProvider"> .... ....