how to write a file to UNC folder

  • Thread starter Thread starter DotNetUser
  • Start date Start date
D

DotNetUser

I know the Domain, UserName, Password and folder on the
domain:\\inpsol301\home$\abc

Supposed I can use UserName, Password and Window Explore to map the folder
above to X: and then write a file to it.

Question: How can I do it programmatically without mapping the drive?

full source code is most welcome!





Thanks in advance
 
You don't need to map a drive, but if you need to connect to a remote share
using different credentials than your current login credentials, you have
to:
1. establish a use record (see net use /? command), or
2. you have to create a new login session (P/Invoking Win32 API LogonUser
specifying the remote credentials) and impersonate.
there is no way arrount this.
The easiest is to create a network session (use record) from a logon script
(net use \\server\share pwd user:....).
You can also create a use record from code (P/Invoke NetUseAdd), but why
complicate things.
Willy.
 
I tried to impersonate using P/Invoke. But it seems not working. I am in the
network, but my computer is not joined to the domain. I can access Internet,
when I want to access some resource in the domain, I map the local drive to
that resource folder.
Question is:
How can I do it without mapping the local drive to the resource folder
programmatically?

Thanks in advance
 
DotNetUser said:
I tried to impersonate using P/Invoke. But it seems not working. I am in
the
network, but my computer is not joined to the domain. I can access
Internet,
when I want to access some resource in the domain, I map the local drive
to
that resource folder.
Question is:
How can I do it without mapping the local drive to the resource folder
programmatically?


What problem did you have when impersonating. Please post your offending
code.

Willy.
 
Back
Top