problems with authenication in C#

K

kj96

I have a intranet page that I want to use to open a certain file from a
network location make changes to it and then write the changed file
back to the same network location

<my try at the code>

TextReader tr = new StreamReader("\\\\server\\location\\text1.txt");

StreamWriter tw = new StreamWriter("\\\\server\\location\\text2.txt");
</my try at the code>

I have setup IIS to use a domain user account that has read and write
rights to the server location.

I get the following error.
********************************************************************************

Server Error in '/web' Application.
--------------------------------------------------------------------------------

Logon failure: unknown user name or bad password.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Logon failure: unknown user
name or bad password.

Source Error:


Line 64: TextReader tr = new StreamReader
("\\\\server\\location\\file1.txt");

Line 66: StreamWriter tw = new
StreamWriter("\\\\server\\location\\file2.txt");


Source File: c:\inetpub\wwwroot\web\default.aspx.cs Line: 64

Stack Trace:


[IOException: Logon failure: unknown user name or bad password.
]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +723
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +859
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize) +44
System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
detectEncodingFromByteOrderMarks, Int32 bufferSize) +79
System.IO.StreamReader..ctor(String path) +101
web.WebForm1.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\web\default.aspx.cs:64
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263
Kevin Joyner
Systems Analyst
 
A

Angel J. Hernández

Hi there... which user is being authenticated (IUSR_MACHINENAME) ? Remember
that it belongs to the Guests user group. The same privileges as user but
with more restrictions. Does the user being authenticated have access to
that folder (Security)? Does the user being authenticated have the
corresponding checkboxes selected in your case read/write attributes?
Check those things out first and try again...

Regards,


--
Angel J. Hernández M.
MCSD


kj96 said:
I have a intranet page that I want to use to open a certain file from a
network location make changes to it and then write the changed file
back to the same network location

<my try at the code>

TextReader tr = new StreamReader("\\\\server\\location\\text1.txt");

StreamWriter tw = new StreamWriter("\\\\server\\location\\text2.txt");
</my try at the code>

I have setup IIS to use a domain user account that has read and write
rights to the server location.

I get the following error.
****************************************************************************
****

Server Error in '/web' Application.
-------------------------------------------------------------------------- ------

Logon failure: unknown user name or bad password.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Logon failure: unknown user
name or bad password.

Source Error:


Line 64: TextReader tr = new StreamReader
("\\\\server\\location\\file1.txt");

Line 66: StreamWriter tw = new
StreamWriter("\\\\server\\location\\file2.txt");


Source File: c:\inetpub\wwwroot\web\default.aspx.cs Line: 64

Stack Trace:


[IOException: Logon failure: unknown user name or bad password.
]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +723
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy) +859
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize) +44
System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
detectEncodingFromByteOrderMarks, Int32 bufferSize) +79
System.IO.StreamReader..ctor(String path) +101
web.WebForm1.Button1_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\web\default.aspx.cs:64
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1263
Kevin Joyner
Systems Analyst
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top