ASP.NET 无法连接到 SQL Server 2005

发布于 2024-07-08 14:05:12 字数 312 浏览 6 评论 0原文

我正在尝试创建一个与 SQL Server 2005 数据库(与 ASP 服务器分开的服务器)有桥接连接的 ASP 页。 为此,我尝试使用 Windows 身份验证设置。 我的名字拥有 SQL Server 的完全权限,但我仍然收到错误“用户 COMPANY\name 登录失败”。 为了查看这是否只是 Windows 身份验证问题,我尝试进行 SQL Server 身份验证; 这也不会让我登录。 我不知道为什么 SQL 身份验证会出现问题,但我真的可以使用一些帮助来弄清楚为什么 Windows 身份验证不起作用。 感谢您的时间。

问候,

弗朗哥

I'm trying to create an ASP page that has a bridged connection with an SQL Server 2005 database (separate sever from the ASP's server). For this I am trying to use a Windows Authentication setup. I have my name with full rights to the SQL server yet I am still getting the error 'Login failed for user COMPANY\name'. To see if this was just a Windows Authentication problem I tried to do a SQL Server Authentication; This also will not let me login. I have no idea why there would be a problem with the SQL Authentication, but I could really use some help figuring out why the Windows Authentication won't work. Thank you for your time.

Regards,

Franco

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

怪异←思 2024-07-15 14:05:13

我假设它们位于同一域(因为您提到了公司\名称)?

Manke确认SQL Server已设置为允许远程连接。 (服务和连接的外围区域配置)

如果您使用 Windows Auth,您是否尝试指定单个用户进行连接,或者使用当前用户的身份? 如果您希望指定始终连接的单个用户,我建议使用 SQL Server 帐户而不是域帐户。

I assume these are on the same domain (since you mentioned COMPANY\name)?

Manke sure SQL Server is set to allow remote connections. (Surface Area Configuration for Services and Connections)

If you are using Windows Auth, are you trying to specify a single user to connect as, or is the current user's identity used? If you wish to speify a single user to always connect as, I would recommend a SQL Server account instead of a domain account.

清音悠歌 2024-07-15 14:05:13

你说,当你尝试使用 SQL 身份验证(我猜是 SQL Server 用户 ID 和密码)登录 SQL Server 时,它没有让你进入。这意味着 SQL Server 端存在一些问题。 确保您的 SQL Server 设置为混合模式身份验证。 这意味着它应该能够让您使用 Windows 身份验证以及如果您提供 sql server 用户 ID 和密码。

那是一个指针。 还有一点,正如这里每个人所说的,不要使用 Windows 身份验证从 ASP 页面连接到 SQL Server。 为此,您需要将域用户设置为 SQL Server 用户。 今天您是唯一使用此页面的人,明天您需要将此页面提供给整个组织时怎么样?

You said, when you tried logging into SQL Server using your SQL Authentication (I guess it is SQL Server user id and password), it didn't let you in. That means there is some problem at the SQL Server end. Make sure that your SQL Server is setup for mixed mode authentication. Meaning it should be able to let you in using windows authentication as well as if you provide sql server user id and password.

That is one pointer. Another point as everyone here is saying, don't use windows authentication to connect to SQL Server from ASP page. For this to work you need to setup the domain user to be a SQL Server user. Today you are the only one using this page, how about tomorrow when you need to give this page to entire org?

晒暮凉 2024-07-15 14:05:13

不要对此类连接使用 Windows 身份验证。

您能否发布您用于 WA 和 SQLauth 的连接字符串的副本(已清理 - 更改密码)?

Dont use Windows authentication for this kind of connection.

Can you post a copy of the connection string (sanitized - change the password) you are using for both WA and SQLauth?

不甘平庸 2024-07-15 14:05:13

尝试删除用户名的域部分 - COMPANY\User - 它可能会干扰身份验证。

另外 - 在 SQL Server 上(如果您有访问权限),您是否尝试通过 localhost 连接到服务器? 可能只是您的用户没有足够的权限。

SQL Server Auth - 您是否创建了用户并将其附加到具有读取权限的数据库?

Try stripping out the domain part of your username - COMPANY\User - it may be interfering with the authentication.

Also - on the SQL Server (if you have access), have you tried connecting to the server via localhost? It could just be that your user doesn't have enough priveledges.

SQL Server Auth - have you created a user and attached them to a database with read priveledges?

拒绝两难 2024-07-15 14:05:13

安装 SQL Server 时,是否将其配置为使用混合模式身份验证? 您还可以直接使用 SQL Management Studio、使用 SQL 身份验证或 Windows 身份验证进行连接吗?

When you installed SQL Server, did you configure it to use mixed mode authentication? Also can you connect to using SQL Management Studio directly, using SQL authentication or Windows authentication?

深海不蓝 2024-07-15 14:05:13

我非常确定它不能位于 SQL Server 端,因为我能够从与我现在尝试连接的服务器完全不同的服务器进行连接。 难道是我使用的服务器有问题吗? 如果是这样,可能的解决方案是什么?

与一些同事交谈时,他们说他们过去没有尝试过连接到该服务器。 我只是觉得很奇怪,我可以从一台服务器连接,但不能从另一台服务器连接。

I'm pretty sure that it can't be on the SQL Server end because I am able to connect from a completely different server then the one I am trying to connect from now. Could it be a problem from the server which I am using? If so, what are possible solutions?

Talking to some fellow employees they say they haven't tried to connect to this server in the past. I just find it weird that I am able to connect from one server but not another.

迎风吟唱 2024-07-15 14:05:13

以下是当您从 ASP.NET 应用程序建立数据库连接时遇到问题时要执行的步骤清单。

  1. 您可以从 ASP.NET 服务器 ping 数据库服务器吗?
  2. 您可以使用 SQL 身份验证和 Management Studio 从 ASP.NET 服务器连接到数据库吗?
  3. 编写一个包含非常简单的小返回查询的页面作为测试。 可以用测试页查询数据库吗? 不要依赖任何 web.config 条目,手动输入所有连接字符串和查询数据(不要将此测试页留在服务器上超过测试所需的时间)
  4. 如果您的测试页失败,错误是什么? 如果您从 ASP.NET 服务器控制台进行测试,您应该会收到可能指示问题的详细错误。
  5. 如果您有多个服务器数据库,请绝对确保您正在连接到您认为的服务器;)

一般提示:
Management Studio 可能是最好的测试 - 如果您可以通过 Management Studio 从 ASP.NET 服务器通过 Windows 和 SQL 身份验证进行连接,那么问题一定出在您的 ASP.NET 应用程序配置上。

您提到您收到显式身份验证错误,表明“COMPANY\name”未经授权。 您正在运行域控制器吗? “COMPANY”是域名吗? 如果不是,ASP.NET 可能无法使用您的域帐户对数据库进行身份验证。

如果必须使用 Windows 授权,请记住在 web.config 中启用模拟:

<identity impersonate="true" />

您还需要在站点的 IIS 配置中禁用匿名访问并启用集成安全性。

HTH。

Here's a checklist of steps to go through when you have trouble making a database connection from an ASP.NET application

  1. Can you ping the database server from the ASP.NET server?
  2. Can you connect to the database using SQL Authentication and Management Studio from the ASP.NET server?
  3. Write a page with a very simple, small-return query to use as a test. Can you query the database with the test page? Don't rely on any web.config entries, manually enter all connection string and query data (don't leave this test page on the server longer than necessary to test)
  4. If your test page fails, what is the error? If you test from the ASP.NET server console you should get a detailed error that may indicate the problem.
  5. If you have multiple server databases, make absolutely sure you're connecting to the server you think you are ;)

General Tips:
Management Studio is probably the single best test- if you can connect through Windows and SQL Authentication via Management Studio from the ASP.NET server, then the problem must be with your ASP.NET application configuration.

You mentioned that you are getting an explicit authentication error that "COMPANY\name" is not authorized. Are you running a domain controller? Is "COMPANY" the domain name? If not, ASP.NET may not be authenticating against the database using your domain account.

If you must use Windows authorization remember to enable impersonation in the web.config:

<identity impersonate="true" />

You will also need to disable Anonymous access and enable Integrated security in the IIS configuration for your site.

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文