Access Network Share from inside an application.

J

Johnny Fugazzi

I would like to access a network share from my vb.net application. I do not
want to map a drive to the share, however. I would also like to specifiy a
user credential to use when connecting to the share, as the user running the
application will not have security rights to hit the share themselves.

Any pointers on this?
 
K

Ken Tucker [MVP]

Hi,

http://www.dotnet247.com/247reference/msgs/28/144136.aspx

Ken
---------------------
I would like to access a network share from my vb.net application. I do not
want to map a drive to the share, however. I would also like to specifiy a
user credential to use when connecting to the share, as the user running the
application will not have security rights to hit the share themselves.

Any pointers on this?
 
J

Johnny Fugazzi

Thanks for the reply.

I am currently using that code to Impersonate a user that has FULL
permissions on the share, and full permissions on the Files and Folders held
within that share.

After Impersonation (and before undoing the impersonation) I am able to
connect to the subdirectory on the share and verify that folder is visible.
I am also able to write out the contents of the subfolder as a test. The
next step is to open an excel file and read out some values. At this point
it fails saying that the File Cannot be found. I know the file path is
valid. Are there other issues here that I am not aware of?

The code module that creates an Excel.Application object and opens the file
is not instantiated and called until after the Impersonation is successful.
But it still appears like it is trying to open the file using the actual
user's security context, and not the impersonated one.

Any help would be appreaciated.
 

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