473,396 Members | 1,608 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,396 software developers and data experts.

Accessing a remote path?


Hi, i searched on google for a resolution for this problem but i found
nothing interesting, i hope someone here will be able to help or at
least hint me.

The problem is simple: i'm trying to access a gile on a netwok PC,
addressing it with a UNC path (ie \\servername\share\file.txt). I use
the File object to do this, but i doesn't work because the remote PC
is on another domain, and i have to provide credentials for that
domain. I do have dose credentials, but i don't know how to use them
in c# code. Is there a way to do this? I seached in the System.IO
namespace, but found nothing...

Any help will be apreciated, thanks!
--
NEURAL
ggenga<at>hotmail<punto>com (ICQ: 8971364)

'Adepto in tutte le arti, Maestro di nessuna'
Nov 15 '05 #1
4 2069
Neural,

What you need to do is imitate that person on the other domain. To do
this, use the LogonUser API function (called through the P/Invoke layer).
Once you have a user handle, you can impersonate that user in the current
process by making a call to the Impersonate method on the WindowsIdentity
class. The documentation for the Impersonate method on the WindowsIdentity
class shows you how to do this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Neural" <do***@spam.com> wrote in message
news:3f****************@news.microsoft.com...

Hi, i searched on google for a resolution for this problem but i found
nothing interesting, i hope someone here will be able to help or at
least hint me.

The problem is simple: i'm trying to access a gile on a netwok PC,
addressing it with a UNC path (ie \\servername\share\file.txt). I use
the File object to do this, but i doesn't work because the remote PC
is on another domain, and i have to provide credentials for that
domain. I do have dose credentials, but i don't know how to use them
in c# code. Is there a way to do this? I seached in the System.IO
namespace, but found nothing...

Any help will be apreciated, thanks!
--
NEURAL
ggenga<at>hotmail<punto>com (ICQ: 8971364)

'Adepto in tutte le arti, Maestro di nessuna'

Nov 15 '05 #2
On Tue, 21 Oct 2003 08:37:31 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
What you need to do is imitate that person on the other domain. To do
this, use the LogonUser API function (called through the P/Invoke layer).


thank you Nicholas, i'll try it.
Nov 15 '05 #3
"Neural" <do***@spam.com> wrote in message
news:3f****************@news.microsoft.com...

Hi, i searched on google for a resolution for this problem but i found
nothing interesting, i hope someone here will be able to help or at
least hint me.

The problem is simple: i'm trying to access a gile on a netwok PC,
addressing it with a UNC path (ie \\servername\share\file.txt). I use
the File object to do this, but i doesn't work because the remote PC
is on another domain, and i have to provide credentials for that
domain. I do have dose credentials, but i don't know how to use them
in c# code. Is there a way to do this? I seached in the System.IO
namespace, but found nothing...

Any help will be apreciated, thanks!
--
NEURAL
ggenga<at>hotmail<punto>com (ICQ: 8971364)

'Adepto in tutte le arti, Maestro di nessuna'


You could also use the WNetAddConnection2() API to authenticate just like
"net use" does. The drawback is that you can only authenticate as a single
user to any given server, so you need to WNetCancelConnection2() when done
with the file. This might also be a problem if mulitiple processes access
files on that server.
Arild
Nov 15 '05 #4
On Tue, 21 Oct 2003 13:06:59 GMT, do***@spam.com (Neural) wrote:
thank you Nicholas, i'll try it.


it worked! i had some trouble making it work, but now it's perfect!
thank you :-)

Nov 15 '05 #5

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

Similar topics

1
by: Anibal David Acosta F. | last post by:
I want to access to MessageQueue from a remote machine, the path ".\private$\myQueue" only works locally, and the path "\\myServer\private$\myQueue" doesn't works. Do you know how can I access?...
36
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC...
1
by: ehilario | last post by:
Hi Mark, The following shows when I call it locally. If you look at the URL that has http://localhost, this is the one I use when I call the ASP page from the same local server (self...
1
by: Max Baki via .NET 247 | last post by:
I all, i've write a sample ftp Windows service which download files and copy them on remote share or remote mapped drive (the service works fine on local drives). This part of code is the...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
5
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
1
by: ken.beutler | last post by:
I am getting a 404 error when trying to access an ASP page from a remote machine (via Internet Explorer). However, the asp page is processed successfully when accessing this page from the local...
4
by: Noy B | last post by:
Hi, I have developed a small application that is using a MSAccess DB. the problem is that it was developed on a machine where the application and the DB are both located. now it needs to be...
1
by: Usenet User | last post by:
From a .NET 1.1 app: need to access a file share on a remote server by its UNC path, i.e., \\server\folder\subfolder\, using specific username and password. The problem is that the credentials...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.