q; access to a remote file

Discussion in 'ASP .Net' started by =?Utf-8?B?SklNLkgu?=, Sep 23, 2006.

  1. \\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();
    }
    }
     
    =?Utf-8?B?SklNLkgu?=, Sep 23, 2006
    #1
    1. Advertising

  2. 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


    "JIM.H." <> wrote in message
    news:...
    > \\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();
    > }
    > }
    >
    >
    >
     
    John Timney \(MVP\), Sep 23, 2006
    #2
    1. Advertising

  3. Thanks for the reply. Can you give me a site that shows how I can do it.

    "John Timney (MVP)" wrote:

    > 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
    >
    >
    > "JIM.H." <> wrote in message
    > news:...
    > > \\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();
    > > }
    > > }
    > >
    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?SklNLkgu?=, Sep 23, 2006
    #3
  4. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp

    --
    --
    Regards

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


    "JIM.H." <> wrote in message
    news:...
    > Thanks for the reply. Can you give me a site that shows how I can do it.
    >
    > "John Timney (MVP)" wrote:
    >
    >> 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
    >>
    >>
    >> "JIM.H." <> wrote in message
    >> news:...
    >> > \\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();
    >> > }
    >> > }
    >> >
    >> >
    >> >

    >>
    >>
    >>
     
    John Timney \(MVP\), Sep 24, 2006
    #4
  5. 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'

    =======

    "John Timney (MVP)" wrote:

    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp
    >
    > --
    > --
    > Regards
    >
    > John Timney (MVP)
    > VISIT MY WEBSITE:
    > http://www.johntimney.com
    >
    >
    > "JIM.H." <> wrote in message
    > news:...
    > > Thanks for the reply. Can you give me a site that shows how I can do it.
    > >
    > > "John Timney (MVP)" wrote:
    > >
    > >> 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
    > >>
    > >>
    > >> "JIM.H." <> wrote in message
    > >> news:...
    > >> > \\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();
    > >> > }
    > >> > }
    > >> >
    > >> >
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?SklNLkgu?=, Sep 24, 2006
    #5
  6. 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


    "JIM.H." <> wrote in message
    news:...
    > 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'
    >
    > =======
    >
    > "John Timney (MVP)" wrote:
    >
    >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp
    >>
    >> --
    >> --
    >> Regards
    >>
    >> John Timney (MVP)
    >> VISIT MY WEBSITE:
    >> http://www.johntimney.com
    >>
    >>
    >> "JIM.H." <> wrote in message
    >> news:...
    >> > Thanks for the reply. Can you give me a site that shows how I can do
    >> > it.
    >> >
    >> > "John Timney (MVP)" wrote:
    >> >
    >> >> 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
    >> >>
    >> >>
    >> >> "JIM.H." <> wrote in message
    >> >> news:...
    >> >> > \\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();
    >> >> > }
    >> >> > }
    >> >> >
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    John Timney \(MVP\), Sep 24, 2006
    #6
  7. 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.




    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "JIM.H." <> wrote in message
    news:...
    > 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'
    >
    > =======
    >
    > "John Timney (MVP)" wrote:
    >
    >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp
    >>
    >> --
    >> --
    >> Regards
    >>
    >> John Timney (MVP)
    >> VISIT MY WEBSITE:
    >> http://www.johntimney.com
    >>
    >>
    >> "JIM.H." <> wrote in message
    >> news:...
    >> > Thanks for the reply. Can you give me a site that shows how I can do it.
    >> >
    >> > "John Timney (MVP)" wrote:
    >> >
    >> >> 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
    >> >>
    >> >>
    >> >> "JIM.H." <> wrote in message
    >> >> news:...
    >> >> > \\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();
    >> >> > }
    >> >> > }
    >> >> >
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Juan T. Llibre, Sep 24, 2006
    #7
  8. 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?

    "Juan T. Llibre" wrote:

    > 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.
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > aspnetfaq.com : http://www.aspnetfaq.com/
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "JIM.H." <> wrote in message
    > news:...
    > > 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'
    > >
    > > =======
    > >
    > > "John Timney (MVP)" wrote:
    > >
    > >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp
    > >>
    > >> --
    > >> --
    > >> Regards
    > >>
    > >> John Timney (MVP)
    > >> VISIT MY WEBSITE:
    > >> http://www.johntimney.com
    > >>
    > >>
    > >> "JIM.H." <> wrote in message
    > >> news:...
    > >> > Thanks for the reply. Can you give me a site that shows how I can do it.
    > >> >
    > >> > "John Timney (MVP)" wrote:
    > >> >
    > >> >> 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
    > >> >>
    > >> >>
    > >> >> "JIM.H." <> wrote in message
    > >> >> news:...
    > >> >> > \\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();
    > >> >> > }
    > >> >> > }
    > >> >> >
    > >> >> >
    > >> >> >
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?SklNLkgu?=, Sep 27, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?cmV5Y29u?=

    can't access file on a remote file server

    =?Utf-8?B?cmV5Y29u?=, Jun 3, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,079
    agrnidhi
    May 24, 2007
  2. davidj411
    Replies:
    7
    Views:
    3,290
    Tim Golden
    Oct 8, 2009
  3. william

    Access remote access database from ASP

    william, Feb 10, 2004, in forum: ASP General
    Replies:
    5
    Views:
    138
    william
    Feb 13, 2004
  4. CJM
    Replies:
    2
    Views:
    114
  5. Dayton Jones

    Remote.pm (File::Remote) problem

    Dayton Jones, Mar 1, 2006, in forum: Perl Misc
    Replies:
    9
    Views:
    195
    Dayton Jones
    Mar 3, 2006
Loading...

Share This Page