Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL integrated security using computer name instead of user name

I am trying to an SQL Express instance on the same network, authenticating with my domain user. It works just fine with Windows Authentication in SSMS. I verified that I can use the MyDB database, including editing tables.

However, when I try the following connection string:

Server=ipaddress\SQLExpress; Database=MyDB; Integrated Security=SSPI;

I get back an error:

Cannot open database "MyDB" requested by the login. The login failed. Login failed for user 'ROMANIA\MONSTER2$'

The problem is that MONSTER2 is the name of my computer, not my username. (ROMANIA is the domain.) What am I doing wrong?

[Edit] I forgot something that might be relevant: I am trying to open the connection from a webservice running on my computer.

like image 639
Marcel Popescu Avatar asked Jul 20 '11 12:07

Marcel Popescu


People also ask

What is integrated security SQL?

Integrated security uses the current Windows identity established on the operating system thread to access the SQL Server database. You can then map the Windows identity to a SQL Server database and permissions.

How do I enable integrated security in SQL Server?

To implement SQL Server integrated security, perform the following steps: From SQL Enterprise Manager, right-click the SQL Server name that appears in the Server Manager window and click Configure on the shortcut menu. Click Security Options. Select Windows NT Integrated as the Login Security Mode, and then click OK.

What is integrated security in Windows?

Windows integrated security authentication (often referred to as Windows authentication) is the easiest security mechanism to implement. The basic vision is beautiful in its simplicity: if the user has already logged on to Windows, the browser can silently pass the user's credentials to ASP.NET.


1 Answers

Your web service is running under the NT AUTHORITY\Network Service security context. This will cause the process to use the host's machine account when accessing network resources in the domain.

You'll have to configure the web service to run with your domain identity.

If you're hosting your web service in IIS, you can do this through impersonation. Here's an example:

<configuration>     <system.web>         <identity             impersonate="true"             userName="ROMANIA\username"              password="********" />     </system.web> </configuration> 
like image 122
Enrico Campidoglio Avatar answered Sep 27 '22 19:09

Enrico Campidoglio