none
"Could not find a part of the path" error message when you access a mapped drive

    Question

  • Hi

    I'm getting error when I try to access to a mapped drive.

    I'm using vb.net 2003 and developing a windows service. The service needs to read a file on a mapped drive using the streamreader class.

    When I run the service on windows XP pro all works perfect, but now when I run the same service on the Windows 2003 server it doesn’t work.

    The mapped drive exists and I grant access to everyone. I’ve found an article that says the problem but doesn’t have the solution.

    The article is:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;827421#appliesto

    Hope you can help me,

    Please answer me to the e-mail nuno.rally@iol.pt 

     

    Thanks

     

     

    Tuesday, February 14, 2006 11:45 AM

Answers


  • The difference is that the service running on 2003 Server is running under a different account. When you're running locally on your XP machine it's probably executing under your domain account, which has sufficient permissions to access the resource.

    If you're getting an access denied error that means you need to provide sufficient permissions to the resource for the account under which the service is running on the Windows 2003 Server machine. The easy way to do this is to run the Windows Service under a domain account. If it's running under a local account then you will need to have a matching local account on the other machine with identical credentials (account ID and password).

    Tuesday, February 14, 2006 6:23 PM

All replies


  • The MS KB article you posted *does* have a workaround. However, I was wondering if there was a reason why you can't use the UNC path instead of a mapped path?
    Tuesday, February 14, 2006 2:51 PM
  • Hi Paul,

    Thanks for your answer, but i've already try with the UNC path. The error with the UNC path is "Access denied to the Path". But if i try to open the file with the same path that error says, i can read it.

    If i use the same code as a simple windows application it works too. On XP the service works. It only doesn't work on the windows2003server.

    Have you already try to access to a mapped drive using a windows service on the windows 2003 server?

     

    Best Regards

     

    Nuno

    Tuesday, February 14, 2006 5:16 PM

  • The difference is that the service running on 2003 Server is running under a different account. When you're running locally on your XP machine it's probably executing under your domain account, which has sufficient permissions to access the resource.

    If you're getting an access denied error that means you need to provide sufficient permissions to the resource for the account under which the service is running on the Windows 2003 Server machine. The easy way to do this is to run the Windows Service under a domain account. If it's running under a local account then you will need to have a matching local account on the other machine with identical credentials (account ID and password).

    Tuesday, February 14, 2006 6:23 PM
  • Hi Paul,

    You're the man.... Thanks. It works. It's possible and the problem was permitions.

    Best Regards

    Nuno

     

    Wednesday, February 15, 2006 11:35 AM
  • Hi,

     

    To be more specific on what needs to be done to solve this problem, here are the steps.

     

    Name

    Description

    Web Server

    The server on which the upload utility application is deployed

    Remote Server

    The machine on which the files are needed to be uploaded.

     

    1.       Go to the IIS on the Web Server. Select the deployed application, right click and select Properties.

    2.       Select the Directory Security tab and click on Edit button of Authentication and Access Control.

    3.       Just Copy the Username (IUSR_XXX) and exit from here. (No changes required here on web server)

    4.       To guide you what we are trying to do here – The ASP.Net uses the identity of username IUSR_XXX for running the application when anonymous access is on. Now for uploading the files on the remote machine, the same user must exist there as well. Otherwise the remote machine does not grant  access to its path as it cannot find the identity of the user under which the web application is running. So it’s necessary to create the same user (IUSR_XXX) on the remote machine as well. Follow the following step to create the user on the remote machine

    a.       On the Remote Server, Go to Administrative Tools -> Computer Management -> Local Users & Groups -> Users  and add a new user with the Username = IUSR_XXX (The one which you have copied from IIS of the web server). Keep the password as blank ie don’t give any password

    b.      Uncheck the “User must change password on next logon  and checkPassword Never Expires” and click create button. This will create the new user

    c.       Go to Groups and double click the group with the name Users. Make sure the newly added user (IUSR_XXX) exists in this group.  If it is not there, add it.

    d.      On the Remote Server, browse to the folder in which you want to upload files. Right click on that folder -> Properties -> Security Tab.

    e.      Here add the newly created user and grant it full access permission.

    f.        That’s it with the Remote server security settings.

    5.       On the Web server, open the web.config of the application and give the UNC path (“\\10.10.10.10\inbox”)of the server instead of the mapped path and try running the application. This should solve all the problems.

     

     

    Regards,

    Amit S Bajaj

    Wednesday, September 19, 2007 7:37 AM