ASP.NET - > SQL Server:模拟无法正常工作! [英] ASP.NET -> SQL Server : Impersonation not working!

查看:64
本文介绍了ASP.NET - > SQL Server:模拟无法正常工作!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按如下方式设置我的web.config:

< authentication mode =" Windows" />

< identity impersonate =" true" />


以可以向目标

数据库进行身份验证的用户身份登录我的ASP.NET网站。


1)在WinXP Pro SP1上运行IIS5.1的本地PC上工作正常

2)在Windows 2003服务器上的IIS6.0上不起作用:

系统.Data.SqlClient.SqlException:用户''(null)''登录失败。原因:

与可信的SQL Server连接无关。

在System.Data.SqlClient.ConnectionPool.GetConnection(布尔&

isInTransaction)



System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString选项,布尔& isInTransaction)

在System.Data.SqlClient。 SqlConnection.Open()

at Microsoft.Practices.EnterpriseLibrary.Data.Databas e.OpenConnection()

但是,Environment.UserName返回正确的用户名!

为什么?如何修复?

I set my web.config as follows:
<authentication mode="Windows" />
<identity impersonate="true" />

Logon to my ASP.NET website as a user who can authenticate to the target
database.

1) Works fine on my local PC running IIS5.1 on WinXP Pro SP1
2) does not work on IIS6.0 on Windows 2003 server:
System.Data.SqlClient.SqlException: Login failed for user ''(null)''. Reason:
Not associated with a trusted SQL Server connection.
at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.Practices.EnterpriseLibrary.Data.Databas e.OpenConnection()
HOWEVER, Environment.UserName returns the correct username!
Why? How to fix?

推荐答案

> 2)在Windows 2003服务器上的IIS6.0上不起作用:
> 2) does not work on IIS6.0 on Windows 2003 server:
System.Data.SqlClient.SqlException:登录失败,用户''(null)''。
原因:
与受信任的SQL Server连接无关。
System.Data.SqlClient.SqlException: Login failed for user ''(null)''.
Reason:
Not associated with a trusted SQL Server connection.




我花了很多时间来对抗此错误消息并最终确定了它

all out。


你如何指定你想让这个过程模仿的用户名和密码

来冒充?


我解决这个问题的方法如下(假设你没有在IIS中运行

5.0隔离模式):


1.创建一个域用户允许访问SQL Server数据库。


2.在Windows Server 2003 PC上,编辑IIS_WPG用户组并添加已配置的

用户。


3.右键单击IIS管理器中的DefaultAppPool,然后选择属性。在身份选项卡上,选择可配置按钮。然后在相应的框中输入DOMAIN \ UserName

和密码值。


4.返回IIS管理器,选择您网站的属性,确保它的应用程序池设置为DefaultAppPool,它有一个Application

名称(如果没有设置则单击Create)并确定执行权限

仅限脚本。


完成这一切后,它对我来说很好,使用用户凭据

输入应用程序池作为其模拟用户。


希望有所帮助,


-


( O)enone



I spent a lot of time fighting this error message and eventually figured it
all out.

How are you specifying the username and password that you want the process
to impersonate?

The way I solved this was as follows (this assumes you''re not running in IIS
5.0 isolation mode):

1. Create a domain user that is allowed to access the SQL Server database.

2. On your Windows Server 2003 PC, edit the IIS_WPG usergroup and add the
user you have configured.

3. Right-click the DefaultAppPool in IIS Manager and select Properties. On
the Identity tab, select "Configurable" and then enter the DOMAIN\UserName
and Password values into the appropriate boxes.

4. Back in IIS Manager, select Properties for your web site and ensure that
its Application pool is set to DefaultAppPool, that it has an Application
name (click Create if it''s not set) and that the Execute permissions are set
to Scripts only.

With this all done, it worked fine for me, using the user credentials
entered against the Application pool as its impersonation user.

Hope that helps,

--

(O)enone


我不希望连接到SQL Server的固定域名

用户名/密码,而是我想要的用户将用户名/密码

从Web浏览器传递到IIS6,用于IIS6 / ASP.NET将凭据传递给

SQL Server。


" Oenone"写道:
What I do NOT want connection to the SQL Server to be with a fixed Domain
username/password, but rather I want the user to pass the username/password
from the web browser to IIS6 and for IIS6/ASP.NET to pass the credentials to
SQL Server.

"Oenone" wrote:
2)在Windows 2003服务器上的IIS6.0上不起作用:
System.Data.SqlClient.SqlException:登录失败for user''(null)''。
原因:
与可信的SQL Server连接无关。
2) does not work on IIS6.0 on Windows 2003 server:
System.Data.SqlClient.SqlException: Login failed for user ''(null)''.
Reason:
Not associated with a trusted SQL Server connection.



我花了很多时间来对抗这个错误消息并最终将其全部用完了。

如何指定您希望该过程模仿的用户名和密码?

方式我解决了这个问题如下(这假设你没有在IIS中运行
5.0隔离模式):

1.创建一个允许访问SQL Server数据库的域用户。

2.在Windows Server 2003 PC上,编辑IIS_WPG用户组并添加已配置的
用户。

3.右键单击IIS中的DefaultAppPool管理员并选择属性。在身份选项卡上,选择可配置按钮。然后在相应的框中输入DOMAIN \UserName
和密码值。

4.返回IIS管理器,为您的网站选择属性并确保其应用程序pool设置为DefaultAppPool,它具有应用程序名称(如果未设置则单击创建)并且执行权限仅设置为脚本。

完成这一切后,它对我来说很好,使用针对应用程序池输入的用户凭据作为其模拟用户。

希望有所帮助,

- -

(O)enone



I spent a lot of time fighting this error message and eventually figured it
all out.

How are you specifying the username and password that you want the process
to impersonate?

The way I solved this was as follows (this assumes you''re not running in IIS
5.0 isolation mode):

1. Create a domain user that is allowed to access the SQL Server database.

2. On your Windows Server 2003 PC, edit the IIS_WPG usergroup and add the
user you have configured.

3. Right-click the DefaultAppPool in IIS Manager and select Properties. On
the Identity tab, select "Configurable" and then enter the DOMAIN\UserName
and Password values into the appropriate boxes.

4. Back in IIS Manager, select Properties for your web site and ensure that
its Application pool is set to DefaultAppPool, that it has an Application
name (click Create if it''s not set) and that the Execute permissions are set
to Scripts only.

With this all done, it worked fine for me, using the user credentials
entered against the Application pool as its impersonation user.

Hope that helps,

--

(O)enone



Patrick写道:
Patrick wrote:
我做什么不希望连接到SQL Server具有固定的域用户名/密码,而是希望用户将
用户名/密码从Web浏览器传递到IIS6和IIS6 / ASP.NET
将凭据传递给SQL Server。
What I do NOT want connection to the SQL Server to be with a fixed
Domain username/password, but rather I want the user to pass the
username/password from the web browser to IIS6 and for IIS6/ASP.NET
to pass the credentials to SQL Server.




啊哈 - 我不是确定在这种情况下你会怎么做...


您是否希望用户凭据是

身份的用户凭据浏览器正在运行? (例如,如果我以MYDOMAIN \ .Fred登录到您的

网络并打开网络浏览器,您是否希望与服务器的

连接位于MYDOMAIN \ .Fred的用户凭据?)

或者您希望用户在浏览器中将其键入表单吗?


-


(O)enone



Aha -- I''m not sure how you''d do it in that case...

Are you wanting the user credentials to be those of the user in whose
identity the browser is running? (For example, if I logged on to your
network as MYDOMAIN\Fred and opened the web browser, would you want the
connection to the server to be under the user credentials of MYDOMAIN\Fred?)
Or would you want the user to type them into a form in the browser?

--

(O)enone


这篇关于ASP.NET - &gt; SQL Server:模拟无法正常工作!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆