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);
}
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?
<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. An easy way to find out is to open the command window and type:
echo %userdomain%