q; access to a remote file

G

Guest

\\MyRemoteServer\F1\F2\F3\This PDF.pdf is accessible thought my IE browser,
so my user has access there.
However the following code gives "Logon failure: unknown user name or bad
password.\r\n"
I need to get this application run under a user that has access to
MyRemoteServer, how should I do this?

void dDialog(string sPath)
{

sPath="\\\\MyRemoteServer\\F1\\F2\\F3\\This PDF.pdf";
System.IO.FileInfo oFile;
try
{
oFile = new System.IO.FileInfo(sPath);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
oFile.Name);
Response.AddHeader("Content-Length", oFile.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(oFile.FullName);
}
catch (Exception ex)
{
Response.Write("Exception: " + ex.Message);
}
finally
{
Response.End();
}
}
 
J

John Timney \(MVP\)

The asp.net account must be a domain account to access UNC paths, so
impersonate a domain user who has access to both the server your codes on
and the one you wish to access.

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 
G

Guest

Thanks John. I put the following lines into Web.config and got the following
error. Is there anything else I need to do? I am suing APS.Net 1.1.

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

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: Unrecognized configuration section 'identity'

=======
 
J

John Timney \(MVP\)

You have to actually give the entries values, like the domain your user is
from and the actual username, and their password. Did you make the mistake
of copying it verbatim.

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 
J

Juan T. Llibre

re:
I put the following lines into Web.config and got the following
error. Is there anything else I need to do? I am suing APS.Net 1.1.

Please don't sue ASP.NET 1.1... ;-)

Seriously, check to see if

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

is inside the <system.web> section of web.config.

Also, check to see that it's not within another configuration section.
 
G

Guest

Hi Juan, I would not but the while application is written in1.1, will there
be any problem if I convert it to 2.0?
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top