webconfig 文件中的 Windows 模拟代码错误
我已将文件夹共享给另一台计算机上的网络内的公共访问,
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows"/>
<identity impersonate="true" userName="******" password="*****"/>
.........
..........
我在 webconfig 文件中声明了以下部分以允许模拟,当我运行应用程序时,
其抛出错误说配置错误 描述:处理服务此请求所需的配置文件期间发生错误。请查看下面的具体错误详细信息并适当修改您的配置文件。
解析器错误消息:无法根据配置文件中指定的凭据创建 Windows 用户令牌。来自操作系统的错误“登录失败:未知的用户名或错误的密码。”
ASPX页面: 我有示例 aspx 页面,其中有以下代码用于从本地计算机移动文件 到网络中的其他机器,通过模拟运行
protected void Page_Load(object sender, EventArgs e)
{
File.Copy(@"C:\temp\CloudURL.txt", @"\\RemoteMachine\D$\temp\CloudURL.txt", true);
}
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
<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. 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
protected void Page_Load(object sender, EventArgs e)
{
File.Copy(@"C:\temp\CloudURL.txt", @"\\RemoteMachine\D$\temp\CloudURL.txt", true);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我为解决这个问题所做的。我希望它能帮助某人。
我运行的是 Windows 8.1 和 IIS 7,我收到了与作者相同的消息。
以下是我解决问题的步骤:
1) 如果尚未在 Windows 中设置,请设置帐户密码,使其与 web.config 文件中的信息匹配
转到电脑设置->账户 ->登录选项并设置密码
2) 在 IIS Windows 功能中添加 Windows 身份验证
a) 右键单击左下角的 Windows 徽标
b) 单击“控制面板”
c) 单击“程序”
d ) 单击“打开或关闭 Windows 功能”
e) 在“Internet 信息服务”下 -> “万维网服务”-> “安全”,选中“Windows 身份验证”
3) 重新启动计算机
4) 在 IIS 管理器的“IIS”组中,单击“身份验证”
5 ) 确保“ASP.Net 模拟”和“Windows 身份验证”的状态已启用
6) 重新启动计算机并重新运行解决方案
另外,请确保您的 web.config 模拟行包含域,例如this :
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.
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
Go to PC settings -> Accounts -> Sign In option and set your password
2) Add Windows authentication in IIS Windows feature
a) Right click on the Windows logo in the bottom left corner
b) Click 'Control panel'
c) Click 'Programs'
d) Click 'Turn Windows features on or off'
e) Under 'Internet Information Services' -> 'World Wide Web Services' -> 'Security', check 'Windows Authentication'
3) Restart the computer
4) In IIS Manager, in the 'IIS' group, click on 'Authentication'
5) Make sure the status of 'ASP.Net Impersonation' and 'Windows Authentication' are Enabled
6) Restart the computer and re-run the solution
Also make sure that your web.config impersonate line contains the Domain like this :
<identity impersonate="true" userName="Domain\user" 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?
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. An easy way to find out is to open the command window and type: