473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Network Share

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
Jul 21 '05 #1
1 1350
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" <pa***************@nz.unisys.com> wrote in message
news:cb***********@si05.rsvl.unisys.com...
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

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a...
1
by: brian.oneil2 | last post by:
Is there a way to install this onto a network file share and allow a team to access it? I would say share a CD from a networked CD drive, but there are multiple CD's that would have to be inserted....
8
by: Lam | last post by:
HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve,...
3
by: musosdev | last post by:
Hi guys Okay, I've setup my projects to open and compile fine in VS2005 using FPSE and remote web, but it's *really* slow. So I thought I'd have a go at doing it the normal way, by loading from...
3
by: Miriam | last post by:
Hello, I created a Windows Service in VB.NET, which is to purge files periodically in the local system and also in the shared network drive. Here is my problem: 1. If I set the “Account”...
4
by: Jeremy S. | last post by:
We're in the process of writing a new Windows Forms app and the desktop support folks want for it to be run from a network share. I know it's possible (i.e., just have the framework on the clients...
2
by: Michael | last post by:
We have an ASP.NET 2.0 web application running on a Windows 2003 domain controller. Part of that application needs to read and write files from and to a network share ( living on a MAC Xserveraid)...
6
by: tendim | last post by:
G'day group. Currently our organization us using VB6 based applications, and I am trying to push forward and migrate some of the smaller things to VB.NET, eventually migrating all applications...
5
by: lmttag | last post by:
ASP.NET 2.0 (C#) application Intranet application (not on the Internet) Using Windows authentication and impersonation Windows Server 2003 (IIS6) Server is a member server on a domain Logged...
0
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, We have a legacy asp application that uses a third party component to upload a file and saves it to a secure network share. The code sets the credentials for the secure network share on the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.