CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Connection to a Networkdrive in a different Domain

 



Pyrofreak
New User

Aug 25, 2011, 4:17 AM

Post #1 of 4 (2164 views)
Connection to a Networkdrive in a different Domain Can't Post

Hey everyone,

I have been using Perl for quiete a while now, but I couldn't find a solution to this Question.

Lets say I work in the domain test1 and I will start my perl scricpt as a user in that domain. But the network drive I need to access is in the domain test2. I have a username and a passwort for that domain to actually map the drive in Windows.

My big problem though is, that I am not allowed to map that drive on the computer.

My question is:

Is there a way to connect to that network drive in the other domain without mapping it? As I said I have a user and a password for the other Domain.

I hope you guys can help me out with this one :)

~Pyrofreak


FishMonger
Veteran / Moderator

Aug 25, 2011, 7:38 AM

Post #2 of 4 (2160 views)
Re: [Pyrofreak] Connection to a Networkdrive in a different Domain [In reply to] Can't Post

You haven't provided enough info, but besides using Windows drive mappings, connections could be made by using UNC paths, ftp, telnet, ssh. It all depends on what type of connection is allowed between the 2 domains.


Pyrofreak
New User

Aug 25, 2011, 9:25 AM

Post #3 of 4 (2155 views)
Re: [FishMonger] Connection to a Networkdrive in a different Domain [In reply to] Can't Post

Hey FishMonger,

sadly I have no information about the system that is used in Domain 2. What I want to do is read files on that drive like this:


Code
open(FILE, "\\\\123.456.789.10\\folder\\test.txt");


All I know about the drive it that I can map it with the regular net use command


Code
net use z: \\123.456.789.10\folder /user:test2\testuser password


If there is a way to just connect to it once with perl using the domain, username and password, it would probably connect to the drive using the regular open(); way.

Does this help? Or do you need more Information ?


Pyrofreak
New User

Aug 26, 2011, 5:02 AM

Post #4 of 4 (2072 views)
Re: [Pyrofreak] Connection to a Networkdrive in a different Domain [In reply to] Can't Post

I figured out a way to do this with Win32::NetResource


Code
use Win32::NetResource; 


my $RemoteName = "\\\\123.456.789.10\\folder";

my $RemoteShare = {
'Scope' => RESOURCE_CONNECTED,
'Type'=> RESOURCETYPE_DISK,
'DisplayType' => RESOURCEDISPLAYTYPE_GENERIC,
'Usage' => RESOURCEUSAGE_CONNECTABLE,
'RemoteName' => $RemoteName,
};

my $UserName = "test2\\testuser";
my $Password = "password";
my $Connection = 0;

Win32::NetResource::AddConnection($RemoteShare,$Password,$UserName,$Connection)
or print "unable to connect to the network\n";

open(FILE, "$RemoteName\\test.txt");


Maybe this will help someone that will have the same Problem at some point ^^


(This post was edited by Pyrofreak on Aug 26, 2011, 5:05 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives