473,796 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing network PCs

Hi,

I'm looking to create a simple application that will copy files from a
folder on one PC on the network to another PC on the network but I am
having a bit of difficulty doing this. The problem is that the network
is not active directory and there is not a common username and
password between the PCs. The only way I can transfer files is if I
first open Windows Explorer and navigate manually to the PC enter the
username and password for access, this is not ideal as I would like
the application to be automated. Is there a way you can access another
PC and pass it a username and password or is there an alternative to
the approach I'm taking.

Any help would be much appreciated.

Thanks

Simon

May 23 '07 #1
4 2452
I'm looking to create a simple application that will copy files from a
folder on one PC on the network to another PC on the network but I am
having a bit of difficulty doing this. The problem is that the network
is not active directory and there is not a common username and
password between the PCs. The only way I can transfer files is if I
first open Windows Explorer and navigate manually to the PC enter the
username and password for access, this is not ideal as I would like
the application to be automated. Is there a way you can access another
PC and pass it a username and password or is there an alternative to
the approach I'm taking.

Any help would be much appreciated.

Thanks
This is a deep subject actually. My own expertise is from the WinAPI/C++
world so I'm not sure what .NET function to rely on off-hand but yes, you
can automate this with a different set of credentials than the logged on
(interactive) user. In fact it's the only practical/safe way to do it. Sorry
I don't know the .NET function to use without looking into it but I'd be
very surprised if there wasn't one (that wraps the WinAPI functions
""NetUseAdd ()" or "WNetAddConnect ion2()" and cousins - you can always use
these of course even in .NET but I'm sure .NET provides its own analogue).
Note that you should also understand how authentication works in general and
how it's related to shared folders in particular (especially if this is for
a commercial app). You can get tripped up otherwise, even if things seem to
work at first. Your best bet is to get hold of "Programmin g Windows
Security" by Keith Brown though I'm not sure if it's in print anymore (it
goes back some years). It's still very relevant however and Chapter 8 in
particular is dedicated to your situation. I can also provide an intro on
this type of authentication in general if you want it. I wrote it some years
ago for a colleague and will post it on request (no API samples however
which I can't post for legal reasons).
May 23 '07 #2
"accyboy198 1" <ac*********@gm ail.comwrote in message
news:11******** **************@ u30g2000hsc.goo glegroups.com.. .
Hi,

I'm looking to create a simple application that will copy files from a
folder on one PC on the network to another PC on the network but I am
having a bit of difficulty doing this. The problem is that the network
is not active directory and there is not a common username and
password between the PCs. The only way I can transfer files is if I
first open Windows Explorer and navigate manually to the PC enter the
username and password for access, this is not ideal as I would like
the application to be automated. Is there a way you can access another
PC and pass it a username and password or is there an alternative to
the approach I'm taking.

Any help would be much appreciated.

Thanks

Simon

The easiest solution for this is to create a "use record" for your login
session.
the command should look like:
"net use \\otherpc\share name passwd /user:validUserO nOtherpc"
The way you do this is by placing a "net use" command in your autoexec.bat
file.
Another option is to execute the above "net use" from your code (using
System.Diagnost ics.Process.Sta rt), this way you can delete the network
connection when done with it.
Note that you can use the IPC$ instead of a share name, this gives you
access to all of the resources on the "other" pc.
Willy.

May 23 '07 #3
The easiest solution for this is to create a "use record" for your login
session.
the command should look like:
"net use \\otherpc\share name passwd /user:validUserO nOtherpc"
The way you do this is by placing a "net use" command in your autoexec.bat
file.
Another option is to execute the above "net use" from your code (using
System.Diagnost ics.Process.Sta rt), this way you can delete the network
connection when done with it.
Note that you can use the IPC$ instead of a share name, this gives you
access to all of the resources on the "other" pc.
There should be a .NET function for this somewhere however since spawning
"net.exe" from code is ugly IMO (and he shouldn't publish his password in a
batch file if he decides to go that route). Also note that IPC$ is really
just a login (authentication ) resource for all intents and purposes (unlike
other resources where a DACL check is immediately conducted against the
resource). Once your're authenticated on the remote machine using IPC$, your
network session on that machine is still subject to normal access checks on
whatever resources you touch (which gets into shared resource permissions vs
normal NTFS permissions but that's another story). Access denied can still
occur IOW if you later touch a resource you don't have access to (whereas
access denied will occur right away if you authenticate against the target
resource from the outset, opposed to IPC$).
May 23 '07 #4
"Larry Smith" <no_spam@_nospa m.comwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
>The easiest solution for this is to create a "use record" for your login
session.
the command should look like:
"net use \\otherpc\share name passwd /user:validUserO nOtherpc"
The way you do this is by placing a "net use" command in your
autoexec.bat file.
Another option is to execute the above "net use" from your code (using
System.Diagnos tics.Process.St art), this way you can delete the network
connection when done with it.
Note that you can use the IPC$ instead of a share name, this gives you
access to all of the resources on the "other" pc.

There should be a .NET function for this somewhere however since spawning
"net.exe" from code is ugly IMO (and he shouldn't publish his password in
a batch file if he decides to go that route). Also note that IPC$ is
really just a login (authentication ) resource for all intents and purposes
(unlike other resources where a DACL check is immediately conducted
against the resource). Once your're authenticated on the remote machine
using IPC$, your network session on that machine is still subject to
normal access checks on whatever resources you touch (which gets into
shared resource permissions vs normal NTFS permissions but that's another
story). Access denied can still occur IOW if you later touch a resource
you don't have access to (whereas access denied will occur right away if
you authenticate against the target resource from the outset, opposed to
IPC$).

Unfortunaly there is no .NET API for this, and if there was, you would have
to pass the credentials anyway (as per WNetAddConnecti on2), Sure, I agree
you shouldn't hard code credentials, but all depends on the security
constraints imposed.
Now I suppose that the OP is talking about a home like environment, so
security is IMO not an issue, he knows the password (guess it's even the
administrators pwd) required to access the other PC's resources, which
implies a non-secured environmant anyway.
In such scenario, storing a pwd in a batch file he owns (say in his user
profile) doesn't impose such a security risk. If it is, or if he cares about
security, he should prompt for the credentials interactively and pass them
to the API he calls whatever this API may be. As to spawning "net use", is
IMO not that ugly, the Process.Start api provides everything to run the
command without showing the command windows, so why you consider this to be
ugly is beyond me, given the fact that there is no .NET API to connect to a
shared resource.
Willy.
May 23 '07 #5

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

Similar topics

1
1828
by: Tony Baker | last post by:
Hi, being a Windows developer and not having anything to do with UNIX/Solaris, I have a few questions about accessing .Net Web Applications from such environments. If a client has a UNIX/Solaris environment, is it possible to put a Windows 2000 box on the network which hosts a .Net web application and access it from other UNIX machines on the network (via Netscape or whatever)? Is this as straight forward as plugging a network cable in...
1
4246
by: Amy Tseng | last post by:
Hi, I am having a problem accessing SQL Server 2000 via UNIX. I am accessing SQL Server 2000 from Solaris using Sybase Open Client (CT-Lib). Here is the error message: CT-LIBRARY error: ct_connect(): network packet layer: internal net library error: Net-Library operation terminated due to disconnect
23
2911
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the same NT domain, each one has its own web server. The web server is always IIS 5.0.
36
16433
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 path with a FSO: Set myFile = Server.CreateObject("Scripting.FileSystemObject").GetFile("\\server2\myshare\myfile.txt") this fails with an Permission Denied. here's the deal:
1
6695
by: TJRobertsJob | last post by:
Was wondering if someone could help. Over the last month I've been developing a small database application, using Access 2000, for use in a friends shop. Everything was going well until about a week ago when I started getting the following error when I would click any buttons on my main form that ran either VB code or an Access Macro: "Error accessing file. Network connection may have been lost.". I know for sure it's not a network...
5
21571
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 folder on mapped network drive (eg. N:\Storage that corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find part of path N:\".
1
4625
by: Z0gS | last post by:
I got this problem for the web application I try to access files on a remote server. string dirs = Directory.GetDirectories(@"E:\vehicles") E drive is a map to a network drive. I get the DirectoryNotFoundException. How do I solve the problem or the is another way to write the code Thank yo
1
9518
by: mbah Sumani via .NET 247 | last post by:
(Type your message here) I Think it's the stupidness of Windows. Why the service can't access network drive but console apps or windows application can do it? So my suggestion is make the program for accessing network drive in console apps, then call it with your windows service.. via windows API ..he..he that should work. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As...
19
2179
by: cj | last post by:
I'm getting terrible response times trying to pull data from VFP tables using .net--like 2 minutes! Can someone help? f:\arcust01 currently contains 187,728 records and is indexed on CUSTNO i:\btn currently contains 5,999,657 records and is indexed on BTN Imports System.Data.OleDb Public Class Form1
2
5198
by: dcblair | last post by:
Hi guys and girls. I can't seem to figure this one out. Here is my setup: Speedtouch 536 DSL Modem, Nexxt 4 Port Wireless Router, CNET CIC 920W Wireless IP Camera. The camera is set up in wireless mode and any computer on the wireless or local area network can see the camera and access the video. The setup went perfect for the internal network. But I cannot for the life of me see why the configurations I have set to see the camera...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10012
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.