简体   繁体   English

webconfig文件中的Windows模拟代码出错

[英]Error with windows impersonation code in webconfig file

I have the following section declared in the webconfig file to allow impersonation , I have shared the folder to public access within the network on the other machine 我在webconfig文件中声明了以下部分以允许模拟,我已将该文件夹共享到另一台机器上的网络内的公共访问

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Windows"/>
    <identity impersonate="true" userName="******" password="*****"/>

.........
..........

when i run the application its throwing error saying 当我运行应用程序时它的抛出错误说

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. 配置错误说明:处理为此请求提供服务所需的配置文件时发生错误。 Please review the specific error details below and modify your configuration file appropriately. 请查看下面的具体错误详细信息并相应地修改配置文件。

Parser Error Message: Could not create Windows user token from the credentials specified in the config file. 分析器错误消息:无法从配置文件中指定的凭据创建Windows用户令牌。 Error from the operating system 'Logon failure: unknown user name or bad password. 操作系统登录失败时出错:未知用户名或密码错误。

Aspx page: I have sample aspx page where i have the following code to move the file from local machine to other machine in the network, which runs through impersonation Aspx页面:我有一个示例aspx页面,其中我有以下代码将文件从本地机器移动到网络中的其他机器,通过模拟运行

protected void Page_Load(object sender, EventArgs e)
 {
 File.Copy(@"C:\temp\CloudURL.txt", @"\\RemoteMachine\D$\temp\CloudURL.txt", true);
}    

This is what I did to solve this issue. 这就是我为解决这个问题所做的工作。 I hope it will help someone. 我希望它能帮助别人。

I'm running Windows 8.1 and IIS 7 and I had the same message as the author. 我正在运行Windows 8.1和IIS 7,并且我有与作者相同的消息。

These are the steps I followed to solve the issue : 以下是我解决问题的步骤:

1) If not already set in Windows, set the password for the account to make it match with the information there is in the web.config file 1)如果尚未在Windows中设置,请设置帐户的密码,使其与web.config文件中的信息匹配

Go to PC settings -> Accounts -> Sign In option and set your password 转到PC设置 - >帐户 - >登录选项并设置密码

2) Add Windows authentication in IIS Windows feature 2)在IIS Windows功能中添加Windows身份验证

a) Right click on the Windows logo in the bottom left corner a)右键单击左下角的Windows徽标

b) Click 'Control panel' b)单击“控制面板”

c) Click 'Programs' c)点击“程序”

d) Click 'Turn Windows features on or off' d)单击“打开或关闭Windows功能”

e) Under 'Internet Information Services' -> 'World Wide Web Services' -> 'Security', check 'Windows Authentication' e)在“Internet信息服务” - >“万维网服务” - >“安全”下,选中“Windows身份验证”

3) Restart the computer 3)重新启动计算机

4) In IIS Manager, in the 'IIS' group, click on 'Authentication' 4)在IIS管理器的“IIS”组中,单击“身份验证”

5) Make sure the status of 'ASP.Net Impersonation' and 'Windows Authentication' are Enabled 5)确保“ASP.Net模拟”和“Windows身份验证”的状态为“已启用”

6) Restart the computer and re-run the solution 6)重新启动计算机并重新运行解决方案

Also make sure that your web.config impersonate line contains the Domain like this : 还要确保您的web.config模拟行包含域,如下所示:

<identity impersonate="true" userName="Domain\\user\u0026quot; password="password" />

I can't tell, because you have rightfully blocked out the username, but if you're not fully declaring the username with the domain name, then it will fail with this error. 我无法分辨,因为你已经正确地阻止了用户名,但是如果你没有用域名完全声明用户名,那么它将失败并显示此错误。

Are you using the domain name? 你在使用域名吗?

<identity impersonate="true" userName="domain\user" password="password" />

Everything else about your setup seems correct. 关于您的设置的其他一切似乎都是正确的

Your domain name could either be the name of the domain you are connected to, or the name of your PC. 您的域名可以是您所连接的域的名称,也可以是您的PC的名称。 An easy way to find out is to open the command window and type: 找到的一个简单方法是打开命令窗口并键入:

echo %userdomain%

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

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