When running tomcat 7 as a windows service I can connect SQLServer with SQLServer Authentication but when connecting through Windows Authentication it seems to fail.
From what I know process running under windows services are user independent and run under a user named "SYSTEM" . Is there a way I can add SYSTEM to SQLServer users ?
Every thing seems to work if I run the code via Eclipse i.e. Under a user process.
You need to add a new Login of your Machine (Machine where your service is running) on MS SQL Server machine.
For example your are on domain "DomainName" and your hostname is "MachineName", you need to add a new Login "DomainName\MachineName$" on SQL Server. Note the $ sign at the end indicates that this is a computer name.
Follow the Steps below to add a new login on MS SQL Server:
Open SQL Server Management Studio and Login as 'sa' user.
Open Security -> Logins
Right Click on Logins and New Login...
Enter the Login name "DomainName\MachineName$" in General Tab
Select Windows Authentication radio box
Select tab "Server Roles" and check the box against "sysadmin"
OK and then Restart your SQL Server Service.
Related
I am trying to create a login in SQL Server Management Studio. I was successful in the creation, but after that I can't login in it. I will leave the steps below
Fixed the problem. Solution
Check your server Properties --> Security --> Server authentication
If SQL Server and Windows Authentication mode selected you will be fine.
If not, Follow steps below:
Right-click on your server
Go to option Security
Check the option "SQL Server and Windows Authentication mode"
Click on Ok button
Restart SQL Express Service ("Windows Key" on keyboard and write "Services", and then Enter key)
After SQL services restarted, you should be able to login with user and password
These are the steps to take to create a login:
Click right on database ,choose security , choose SQL with Windows authentication and Both failed....
Restart SQL Server service
Create database
Create login and a sign the name of database to the user from choosing "Default Database"
Be sure you a sign to user mapping database
Server name :
if local choose the name of computer name that you choose from first if you do not know choose from drop list of server name to see what available name
if you have a ip static put the server name like that :000.00.00.00\\SQLSERVER2019,1433, name and password.
I'm trying to connect to SQL Server by using Windows Authentication with Microsoft SQL Server Management Studio. I have several users created on the machine that runs SQL Server.
Login dialog box won't allow to select other users, except the one that is logged in for the current Windows session.
How can I log into Management Studio as a different user?
Proven by many years way of impersonation: a shortcut or bat to run SSMS:
runas.exe /noprofile /netonly /user:YourDomain\YourAccount ssms
The drawback: the password of AD user to be entered every time you hit that shortcut
If you have few versions of management studio, just replace ssms with a full path to required executable
When SSMS is started then connect to a remote server using windows authentication.
Another way is to impersonate that user after you made a login using your credentials:
USE master
EXECUTE AS LOGIN='Domain\AnotherUser'
SELECT SYSTEM_USER
However, this will require your account to have IMPERSONATE or SysAdmin permissions. Impersonation can be granted by:
GRANT IMPERSONATE ANY LOGIN TO [Domain\YourAdAccount]
Right-click the SSMS icon, hold Shift, then right-click Microsoft SQL Server Management Studio with the year of the version you have installed and select Run as Different User. You will be prompted for Windows login credentials that will be used in Windows authentication in SSMS. You can use another Windows account here and then use SSMS as you typically would without making any additional changes.
I have installed SSMS (v17.1), created a new login at Security -> Logins, changed mode on the server (server: OWNER) to mixed mode. But the username/password combination doesn't seem to work. New Database Query -> SQL Server Authentication -> enter username/password and get error: Cannot connect to OWNER. Login failed for user 'myusername'. HELP!
According to Change Server Authentication Mode when the authentication mode is changed the server has to be restarted. Until restart SQL Server is still using Windows only authentication mode and that is what we can read is SQL Server error log as the reason of 18456 "login failed for user (...)"
I got this to work by following the instructions here: https://serverfault.com/questions/422269/where-can-i-find-the-user-in-this-iis-error-login-failed-for-user-iis-appool-w
All I did was create a user on the database, named IIS APPPOOL\DefaultAppPool, and a login, also named IIS APPPOOL\DefaultAppPool, using Windows authentication, and pointed the user at the login and it worked. Frankly, I'm still not sure why my custom SQL Server user didn't work, but at least I can move forward with my project.
Originally, I can connect to localhost in SQL Server through Windows authentication. But after I changed the login password of PC, I can't. Could you please help me figure out why?
Not too much information provided... but that is common issue for many users.
Check the server account name in the SQL Server Configuration Manager. If you run it under your account, you have to change the password for that service and restart it, or change it to use LocalSystem account.
Open CMD (Ctrl+r) input "services.msc"
Right Click SQL Server (Your Instance) - Properties
Click Tab Log On
Fill this account : your user login
Fill password : your user password, then confirm password then Ok.
Back to services Right click your SQL Server [Instance Name] - Start (picture 1)
Try re-login using windows account at SSMS
This is rather embarrassing, but I accidentally deleted my Windows account from the list of SQL Server 2008 users and I cannot for the life of me figure out how to re-add myself now that I don't have login privileges.
The server is running on my machine and the only other Windows users with access are IUSR, NETWORK SERVICE and SYSTEM. Is there anything I can do short of re-installing?
I also recently deleted my windows account from my local development 2008 server. I was able to use SQL server's Single User Mode to recreate my login and add it to the sysadmin role. It took just a few minutes, and I didn't have to admit my terrible error to anyone.
From MSDN:
Starting SQL Server in single-user mode enables any member of the
computer's local Administrators group to connect to the instance of SQL
Server as a member of the sysadmin fixed server role.
Here's how I reinstated myself:
Exit out of SSMS
Stop any SQL related services. I had to stop Reporting Services. Other SQL services such as SQL Agent will also use up your one, valuable connection.
Stop the SQL service
Start the SQL service with the extra parameter -m. This will put the SQL into Single User Mode. This means that SQL will only accept one connection.
Use sqlcmd to connect to your server with the -E trusted connection option. SQL will accept you into the sysadmin role if you're a local administrator.
In the interactive session, create your login and add to the sysadmins role.
USE master
GO
CREATE LOGIN [domain\username] FROM WINDOWS WITH DEFAULT_DATABASE=[Master]
GO
EXEC sp_addsrvrolemember #loginame=N'domain\username', #rolename=N'sysadmin'
GO
Stop the SQL service, remove the -m parameter and restart the service. You should now be able to go back into SSMS and continue using the server normally.
If you get the message:
Login failed for user 'domain\username'. Reason: Server is in single user
mode. Only one administrator can connect at this time.
Then there is something using your single connection. You'll need to find that service or connection and stop it before you can log in. Check SQL Agent, SQL Reporting Services, SQL Analysis Services etc.
Luckily, this wasn't too hard to fix (not that it should have been hard...)!
This blog post explains the steps for starting SQL Server in Single User Mode, which (for some reason) allowed me to login as my Windows administrator account, add the account to the user list (with CREATE LOGIN), enable the SA user and set its password to something I actually knew, and finally login as SA and give the Windows account sysadmin privileges.
Edit 07/05/13: Try this link instead.
Often SQL Server is installed so that any any local administrator is a SQL Server sysadmin.
If this is your case you can run Management Studio as administrator and then add any other windows user as a login in the Security section.
This solution worked for me.