Grant integrated security access rights for Microsoft SQL Server to LocalSystem account? - sql-server

Suppose my web application runs on a Windows server. It is hosted inside Tomcat, which runs as Windows service under the account LocalSystem. It accesses a Microsoft SQL Server on a remote Windows server. I would like to for the web application to authenticate to the SQL Server using integrated authentication.
From the answer to a previous question I know that the following sequence of SQL commands would enable integrated authentication if Tomcat were to run under the account <your-domain-name>\A1.
CREATE LOGIN [<your-domain-name>\A1] FROM WINDOWS;
CREATE USER [<your-domain-name>\A1];
GRANT ... ON <object-name> TO [<your-domain-name>\A1];
What is the correct SQL syntax for granting similar rights to the Local Systemaccount on host H1, if it can be done?

Local System identifies as the computer account on the local network. The computer account is identified by the computer name with a $ postfix.
So to create a login for the Local System account from host H1 on domain <your-domain-name> you would need to run the following command:
CREATE LOGIN [<your-domain-name>\H1$] FROM WINDOWS;
After that you may run the following commands to grant authorization to this account:
CREATE USER [<your-domain-name>\H1$] FOR LOGIN [<your-domain-name>\H1$];
GRANT ... ON <object-name> TO [<your-domain-name>\H1$];

Related

How do I connect application running as "local admin" to remote database using SQL Authentication, without "sysadmin" rights on the server

I am trying to connect to a remote database with SQL authentication, from an application running as “local admin” on another machine.
I have an SQL database on one machine.
I have mixed mode authentication.
I have an application that launches on another machine, which runs as “local admin”, which means it has to connect to the database with SQL authentication.
As far I know, the application cannot run as anything other than a “local admin” account because it is launched remotely using WMI. I do not want to require as service running on the machine in order to launch the application.
But it can only connect to the database if I give the SQL account “sysadmin” rights on the “server”, so that the “local admin” account can login to the database.
Is there a way to allow an application running as “local admin” to login to the database without being “sysadmin”?
the database already had an account of the same name, which was "SQL account without login" so I had to remove it, so when I added the account to the server, it would recreate it in the database with login.

Login failed for user '{domain}\{user}' SqlClient.SqlException in MVC

When I deploy my app to a server, I'm getting the Login failed message. My DB and app are located on two separate physical machines. However this has not posed a problem when developing and testing locally and connecting out to the DB server; only after publishing.
Steps I've taken To attempt to resolve
In my Web.Config I've set Integrated security to false. When integrated security was true, it was giving the same error but with the machine name in place of the user name.
I placed valid credentials in the User ID: and Password: fields of the Web.Config. The credentials placed in Web.Config are also used to log into Sql Server Management Studio directly.
Within SSMS I've also verified those credentials will work under Windows Authentication and SQL Server Authentication.
Those credentials I've set in the app work when I log into the SSMS using Windows Authentication. Advice on how to resolve this would be greatly appreciated. Thanks!
By default, IIS runs your application under a local machine account. This account does not have any permissions to access your SQL Server. In order to achieve integrated security, you need grant it access. There are a few ways to do it, the thread Add IIS 7 AppPool Identities as SQL Server Logons will get you started.
Another way, which is preferred over adding the IIS account, is to create a service account in Active Directory and setting the App Pool Identity in IIS to the service account. Depending on your environment, you should work with your network admin and or DBA to set this up.
Your last option would be to simply use SQL Authentication.

Login into SQL Server 2014 using windows groups

I have an domain admin user group and I have added it to SQL Server security. My account is added to the group. But I am not able to log in to SQL Server.
If I add my domain account individually to SQL Server, I can login using my Windows account. Can I login into SQL Server via a user group so I do not have to add the each individual account?
Yes, you can. All that is required is to add the windows ad group to whatever role is appropriate to your configuration.
SQL Server supports three types of logins:
A local Windows user account or trusted domain account. SQL Server
relies on Windows to authenticate the Windows user accounts.
Windows group. Granting access to a Windows group grants access to
all Windows user logins that are members of the group.
SQL Server login. SQL Server stores both the username and a hash of
the password in the master database, by using internal authentication
methods to verify login attempts.
Read more here MSDN SQL Authentication
And this article has step by step with screen shots: Step By Step
You can use Windows Authentication Mode, first you need to make sure that the user's identity is verified by Windows then SQL Server validates the account name and password using the Windows principal token in the operating system.
Read more: https://msdn.microsoft.com/en-us/library/ms144284.aspx

Unable to create new DataBase in MS Sql Management Studios

I do not remember the serverauthentication password, so I am using windows authentication. I am not able to do anything.
You need to fulfill the following requirements:
you must be a member of Local Administrators group on the computer where the SQL Server is running.
The SQL Server service must be run under the LocalSystem account.
In this case, when connecting using Windows Authentication, you can check if you have any permissions (check the Logins sub-section of the Security section in the SSMS. If the NT AUTHORITY\SYSTEM is shown there, you can add the needed database. Otherwise you need to bethink the sysadmin login & password.

How do I configure SQL Server to allow access via IIS

I have a web service that stores data in a local SQL Server 2008 database. If I run the web service under my account the web service can successfully access the database. However, if I use the DefaultAppPool (IUSR) account then accessing the database from the web service fails.
How do I set security on SQL Server to allow access to a specific database via IIS?
The specific error message I am getting is:
Login failed for user 'IIS APPPOOL\DefaultAppPool'
You have two options (obvious maybe!):
Instead of using Windows Integrated
Security use SQL Authentication
instead.
If you can't or don't want to, then you have
to create a new user in SQL Server
that relates to that Windows account.
Or (third option) you can change the web service to run under an account that you know works.
I generally run the app pool under a domain user account, that way you control the specific user for each site on your server.
If I can't use a domain account, I'll run the site as "Network Service" - and the user that would correspond to that in SQL would be the machine account (MACHINENAME$ - replace "machinename" with your IIS server name").
If you plan to use the new IIS7 IIS users - which are not windows users - you'll have to use SQL Authentication instead of Windows authentication for your SQL database access.

Resources