简体   繁体   English

标准用户的Microsoft SQL Server登录失败

[英]Microsoft SQL Server login failed for standard user

I'm developing a Windows Forms application which connects to a Microsoft SQL Server database. 我正在开发一个连接到Microsoft SQL Server数据库的Windows Forms应用程序。 Using SQL Server authentication, the login works, also works for Windows authentication when the application is run as administrator. 使用SQL Server身份验证,登录有效,当以管理员身份运行应用程序时,登录也适用于Windows身份验证。

The problem is when it isn't run as administrator, and it is run under a session of a Standard user, the application gives the following error: 问题是当它不是以管理员身份运行时,并且在标准用户的会话下运行时,该应用程序给出以下错误:

Cannot open database DATABASENAME requested by the login. 无法打开登录请求的数据库DATABASENAME。 The login failed. 登录失败。 Login failed for user COMPUTERNAME\\USERNAME 用户COMPUTERNAME \\ USERNAME的登录失败

Login without Admin Mode 不使用管理员模式登录

Most likely your problem is that your database is setup to only have logins defined for administrative users. 最有可能的问题是您的数据库设置为仅为管理用户定义了登录名。 Go into Management Studio as an admin user, and go to the Security -> Logins category... 以管理员用户身份进入Management Studio,然后转到“安全性”->“登录名”类别...

Note : 注意 :

Starting with Windows Vista back in 2007, Microsoft made the very smart decision to limit the ability of applications to make key changes to a user's PC. 从2007年开始使用Windows Vista开始,Microsoft做出了非常明智的决定,即限制应用程序对用户PC进行关键更改的能力。 Only applications with administrator privileges could access important parts of Windows, and users had to specifically enable these apps to “ run as administrator .” 只有具有管理员特权的应用程序才能访问Windows的重要部分,并且用户必须专门启用这些应用程序才能“ 以管理员身份运行 ”。

Adding manifest for .NET Applications 为.NET应用程序添加清单

You can tun your App in Admin mode by adding a manifest file. 您可以通过添加清单文件在Admin模式下调整应用程序。

More reference here 在这里更多参考

The below instructions should work using SQL Server Management Studio 以下说明应使用SQL Server Management Studio起作用

1. SQL Server mixed mode, Windows Authentication and SQL Server (right click SQL instance under Server Management -> Properties -> Security)
2. Add the login to SQL Security -> Logins
3. Add login to the Database -> Security -> Users
4. Assign user permissions for tables and stored procedures (right click table or stored procedure -> properties -> permissions -> search -> browse -> select login -> grant 'select, delete, update' for login as needed)
5. Use connection string: PROVIDER=SQLOLEDB;DATA SOURCE=<ip_address>,<port_number>;NETWORK LIBRARY=dbmssocn;INITIAL CATALOG=<database_name>;User ID=<user_name>;Password=<password>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM