How can I pass user login for UNC path?

  • Thread starter Christopher Jedlicka
  • Start date
C

Christopher Jedlicka

I am trying to write a script that will access files on another
computer on the network but in a seperate domain. In order to access
the files, I need to first authenticate to the other domain as a
different user.

When I access files on another domain via explorer, it prompts for a
username/password. Is there some way I can pass this same information
through scripting to access a computer in the other domain?

I attempted to do this with impersonation, but if I understand
correctly, in order to impersonate a user, the user must exist on the
local computer running the script. The user that I would like to use
exists only on the other domain.

Does anyone know how this can be done?

-Chris
 
J

John Smith

Probably got the wrong end of the stick but can't this be done via XMLHTTP
or does the authentication issue get in the way ?
 
G

Grant Wagner

<url: http://www.devguru.com/Technologies/wsh/quickref/wshnetwork.html />
<url: http://msdn.microsoft.com/library/en-us/script56/html/wsobjwshnetwork.asp />

Instead of shelling out to run NET USE, why not use the methods built into the WshNetwork object?

var n = new ActiveXObject("WScript.Network"); // Server.CreateObject();
n.MapNetworkDrive("", "\\\\server\\path$", false, "user", "password");

I wrote and tested it in WSH, but it should work just as well in ASP, you just need to convert it to VBS (if desired) and change
"new ActiveXObject()" into "Server.CreateObject()".

Christopher said:
I have tried the "net use" command that you recommended and it seems
to work perfectly when I use the command directly. When I use the
command through script though, it correctly executes, but doesn't seem
to have any effect. It's running inside the same script just before I
use the file path and with the same security context with low
application protection in iis. Any reason this wouldn't apply through
script? Aside from the user/server information, I am using it exactly
as you had posted it.

-Chris

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top