How can I pass user login for UNC path?

Discussion in 'ASP General' started by Christopher Jedlicka, Aug 1, 2003.

  1. 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
     
    Christopher Jedlicka, Aug 1, 2003
    #1
    1. Advertising

  2. Christopher Jedlicka

    John Smith Guest

    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 ?


    "Christopher Jedlicka" <> wrote in message
    news:...
    > 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
     
    John Smith, Aug 3, 2003
    #2
    1. Advertising

  3. Christopher Jedlicka

    Grant Wagner Guest

    <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 Jedlicka wrote:

    > 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
    >
    > "Steve van Dongen [MSFT]" <> wrote in message news:<>...
    > > On Sun, 3 Aug 2003 02:08:58 +0000 (UTC), "John Smith"
    > > <> wrote:
    > >
    > > >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 ?
    > > >
    > > >
    > > >"Christopher Jedlicka" <> wrote in message
    > > >news:...
    > > >> 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?

    > >
    > >
    > > If you're using anonymous authentication on this ASP page, you could
    > > set the anonymous user to be the user which has permission to access
    > > the share.
    > >
    > > If you're looking for a code solution, before attempting to access the
    > > share, try executing the command:
    > > net use \\server\ipc$ /u:domain\user password
    > >
    > > var sServer = "whatever";
    > > var sDomain = "somedomain";
    > > var sUser = "somebody";
    > > var sPassword = "thisisnotsecure";
    > > var oShell = Server.CreateObject("WScript.Shell");
    > > oShell.Run("net use \\\\" + sServer + "\\ipc$ /u:" + sDomain + "\\" +
    > > sUser + " " + sPassword, 0 , true);
    > >
    > > Regards,
    > > Steve


    --
    | Grant Wagner <>

    * 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
     
    Grant Wagner, Aug 5, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Joseph
    Replies:
    5
    Views:
    4,365
    Joe Smith
    Aug 13, 2004
  2. =?Utf-8?B?RGVhbiBNY0NhcnRlbg==?=

    Retrieving UNC Path of Mapped Drives on Client Machine

    =?Utf-8?B?RGVhbiBNY0NhcnRlbg==?=, Apr 30, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    5,623
    =?Utf-8?B?RGVhbiBNY0NhcnRlbg==?=
    May 20, 2004
  3. Replies:
    21
    Views:
    16,369
    Harlan Messinger
    Dec 14, 2007
  4. Tony Johansson
    Replies:
    3
    Views:
    16,339
    Patrice
    Jan 2, 2010
  5. Christopher Jedlicka

    How can I pass user login for UNC path?

    Christopher Jedlicka, Aug 1, 2003, in forum: Javascript
    Replies:
    2
    Views:
    136
    Grant Wagner
    Aug 5, 2003
Loading...

Share This Page