How can I pass user login for UNC path?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Jedlicka

    How can I pass user login for UNC path?

    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

    #2
    Re: How can I pass user login for UNC path?

    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 ?


    "Christophe r Jedlicka" <chris101@jedli cka.net> wrote in message
    news:eefec7.030 8010925.41a41f5 c@posting.googl e.com...[color=blue]
    > 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[/color]


    Comment

    • Grant Wagner

      #3
      Re: How can I pass user login for UNC path?

      <url: http://www.devguru.com/Technologies/...shnetwork.html />
      <url: http://msdn.microsoft.com/library/en...wshnetwork.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.CreateOb ject();
      n.MapNetworkDri ve("", "\\\\server\\pa th$", 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.CreateO bject()".

      Christopher Jedlicka wrote:
      [color=blue]
      > 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]" <stevevd@online .microsoft.com> wrote in message news:<9ilpiv85p c6eepufu38bufuv dpmmnvj0gl@4ax. com>...[color=green]
      > > On Sun, 3 Aug 2003 02:08:58 +0000 (UTC), "John Smith"
      > > <john@nospam.sp am> wrote:
      > >[color=darkred]
      > > >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 ?
      > > >
      > > >
      > > >"Christophe r Jedlicka" <chris101@jedli cka.net> wrote in message
      > > >news:eefec7.03 08010925.41a41f 5c@posting.goog le.com...
      > > >> 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?[/color]
      > >
      > >
      > > 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 = "thisisnotsecur e";
      > > var oShell = Server.CreateOb ject("WScript.S hell");
      > > oShell.Run("net use \\\\" + sServer + "\\ipc$ /u:" + sDomain + "\\" +
      > > sUser + " " + sPassword, 0 , true);
      > >
      > > Regards,
      > > Steve[/color][/color]

      --
      | Grant Wagner <gwagner@agrico reunited.com>

      * Client-side Javascript and Netscape 4 DOM Reference available at:
      * http://devedge.netscape.com/library/...ce/frames.html
      * Internet Explorer DOM Reference available at:
      * http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html


      Comment

      Working...