HighTechTalks DotNet Forums  

Network Share

Dotnet Security microsoft.public.dotnet.security


Discuss Network Share in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Paul van't Klooster
 
Posts: n/a

Default Network Share - 06-23-2004 , 06:35 AM






Hi Everyone,

This question may have already been asked before, but I can't seem to find
any answers to it:

In C# I know it is possible to access files using UNC path names, but how do
I access a share on a computer with a different user name and password?

In windows explorer when you try and access a share and you don't have the
correct credentials to access the target computer you get a box for an
username and password.

Is it possible to get this box, or programatically provide the user name and
password to use to access files on a remote computer using C# rather than
getting the "Access Denied" exception? I need to be able to do this without
changing any security settings on the calling or target machines.

I hope anyone can help with this, and I thank you in advance.
Paul



Reply With Quote
  #2  
Old   
Naveen K Kohli
 
Posts: n/a

Default Re: Network Share - 06-24-2004 , 10:34 PM






You can use impersonation to run the thread under a certain user's context.
Look at the documentation for WindowsIdentity class. There is an example
that shows imperosnation. Or you can take a look at the following article
that explains it.

http://www.netomatix.com/ImpersonateUser.aspx

Naveen K Kohli
http://www.netomatix.com


"Paul van't Klooster" <paul.vantklooster (AT) nz (DOT) unisys.com> wrote

Quote:
Hi Everyone,

This question may have already been asked before, but I can't seem to find
any answers to it:

In C# I know it is possible to access files using UNC path names, but how
do
I access a share on a computer with a different user name and password?

In windows explorer when you try and access a share and you don't have the
correct credentials to access the target computer you get a box for an
username and password.

Is it possible to get this box, or programatically provide the user name
and
password to use to access files on a remote computer using C# rather than
getting the "Access Denied" exception? I need to be able to do this
without
changing any security settings on the calling or target machines.

I hope anyone can help with this, and I thank you in advance.
Paul





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.