Map network drive for user using VB/ASP.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

    Map network drive for user using VB/ASP.NET

    Hello,

    I'm trying to create an admin page that can run miscellaneous scripts for
    our IT department. Currently, I'm trying to create a script that can map a
    network drive for a user (e.g. a form where I can input \\path\folder, drive
    letter, and domain\user). Is this possible? If so, can someone point me in
    the right direction?

    Thank you,
    Brian Nicholson
  • kimiraikkonen

    #2
    Re: Map network drive for user using VB/ASP.NET

    On Jun 29, 11:42 pm, Brian Nicholson
    <BrianNichol... @discussions.mi crosoft.comwrot e:
    Hello,
    >
    I'm trying to create an admin page that can run miscellaneous scripts for
    our IT department. Currently, I'm trying to create a script that can map a
    network drive for a user (e.g. a form where I can input \\path\folder, drive
    letter, and domain\user). Is this possible? If so, can someone point me in
    the right direction?
    >
    Thank you,
    Brian Nicholson
    Hi,
    If you're meaning to transfer files across computers that are on the
    same network, you can simply use it by calling mapped computer's name
    with UNC path or network IP address:

    My.Computer.Net work.DownloadFi le("\\MAPPED_PC \folder\file.ex e",c:
    \file.exe")

    Additionaly, you need to set networkCredenti als parameter if your
    drives require network authentecation.

    Hope this helps,

    Onur Güzel

    Comment

    • kimiraikkonen

      #3
      Re: Map network drive for user using VB/ASP.NET

      On Jun 30, 1:09 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
      On Jun 29, 11:42 pm, Brian Nicholson
      >
      <BrianNichol... @discussions.mi crosoft.comwrot e:
      Hello,
      >
      I'm trying to create an admin page that can run miscellaneous scripts for
      our IT department. Currently, I'm trying to create a script that can mapa
      network drive for a user (e.g. a form where I can input \\path\folder, drive
      letter, and domain\user). Is this possible? If so, can someone point me in
      the right direction?
      >
      Thank you,
      Brian Nicholson
      >
      Hi,
      If you're meaning to transfer files across computers that are on the
      same network, you can simply use it by calling mapped computer's name
      with UNC path or network IP address:
      >
      My.Computer.Net work.DownloadFi le("\\MAPPED_PC \folder\file.ex e",c:
      \file.exe")
      >
      Additionaly, you need to set networkCredenti als parameter if your
      drives require network authentecation.
      >
      Hope this helps,
      >
      Onur Güzel
      However you can do it also with System.IO.File. Copy using UNC

      and, correcting my previous syntax as:

      My.Computer.Net work.DownloadFi le("\\MAPPEDPC\ \file.exe","c:\ file.exe")

      or one of System.IO.File' s methods to work with your mapped drive on
      domain / workgroups using proper credentials.

      HTH,

      Onur G.

      Comment

      • Mr. Arnold

        #4
        Re: Map network drive for user using VB/ASP.NET


        "Brian Nicholson" <BrianNicholson @discussions.mi crosoft.comwrot e in
        message news:2906FEFC-3E9A-4BAB-B0FA-9C3E339E516E@mi crosoft.com...
        Hello,
        >
        I'm trying to create an admin page that can run miscellaneous scripts for
        our IT department. Currently, I'm trying to create a script that can map a
        network drive for a user (e.g. a form where I can input \\path\folder,
        drive
        letter, and domain\user). Is this possible? If so, can someone point me in
        the right direction?
        >
        As someone else said, you might not find a VB example, and as a good .Net
        programmer, you need to know C# and VB. It's not that hard to translate.
        There is no reason that you can't use the class for an ASP.Net solution.

        There is also no reason you couldn't just take the class talked about as is,
        compile as a C# dll, and set reference to the DLL and use it in your VB
        project.



        Comment

        • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

          #5
          Re: Map network drive for user using VB/ASP.NET

          "Mr. Arnold" wrote:
          >
          As someone else said, you might not find a VB example, and as a good .Net
          programmer, you need to know C# and VB. It's not that hard to translate.
          There is no reason that you can't use the class for an ASP.Net solution.
          >
          There is also no reason you couldn't just take the class talked about as is,
          compile as a C# dll, and set reference to the DLL and use it in your VB
          project.
          >

          >
          >
          Thank you for the response. I have no problems using C# code; I just asked
          that initially because it's what I'm most familiar with. I've come across
          that class before, but the problem is that it requires the password of the
          user I'm mapping a network drive for. I was hoping there was some way I
          could use IIS Windows Authentication or something similar to do this with an
          account that has administrative rights, so I wouldn't be required to know the
          user's password.

          Comment

          • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

            #6
            Re: Map network drive for user using VB/ASP.NET

            "Brian Nicholson" wrote:
            "Mr. Arnold" wrote:

            As someone else said, you might not find a VB example, and as a good .Net
            programmer, you need to know C# and VB. It's not that hard to translate.
            There is no reason that you can't use the class for an ASP.Net solution.

            There is also no reason you couldn't just take the class talked about as is,
            compile as a C# dll, and set reference to the DLL and use it in your VB
            project.


            Thank you for the response. I have no problems using C# code; I just asked
            that initially because it's what I'm most familiar with. I've come across
            that class before, but the problem is that it requires the password of the
            user I'm mapping a network drive for. I was hoping there was some way I
            could use IIS Windows Authentication or something similar to do this with an
            account that has administrative rights, so I wouldn't be required to know the
            user's password.
            I posted this same question in the ASP.NET newsgroup -- it appears what I
            would like to do isn't feasible without resorting to ActiveX. Thanks for the
            replies.

            Comment

            • Mr. Arnold

              #7
              Re: Map network drive for user using VB/ASP.NET


              "Brian Nicholson" <BrianNicholson @discussions.mi crosoft.comwrot e in
              message news:2FA25F8D-2123-4AC2-8397-E5950CEF522D@mi crosoft.com...
              "Brian Nicholson" wrote:
              >
              >"Mr. Arnold" wrote:
              >
              As someone else said, you might not find a VB example, and as a good
              .Net
              programmer, you need to know C# and VB. It's not that hard to
              translate.
              There is no reason that you can't use the class for an ASP.Net
              solution.
              >
              There is also no reason you couldn't just take the class talked about
              as is,
              compile as a C# dll, and set reference to the DLL and use it in your VB
              project.
              >

              >
              >
              >Thank you for the response. I have no problems using C# code; I just
              >asked
              >that initially because it's what I'm most familiar with. I've come
              >across
              >that class before, but the problem is that it requires the password of
              >the
              >user I'm mapping a network drive for. I was hoping there was some way I
              >could use IIS Windows Authentication or something similar to do this with
              >an
              >account that has administrative rights, so I wouldn't be required to know
              >the
              >user's password.
              I posted this same question in the ASP.NET newsgroup -- it appears what I
              would like to do isn't feasible without resorting to ActiveX. Thanks for
              the
              replies.
              I kind of doubt that.

              Comment

              • Mr. Arnold

                #8
                Re: Map network drive for user using VB/ASP.NET


                "Brian Nicholson" <BrianNicholson @discussions.mi crosoft.comwrot e in
                message news:24D9F15B-7085-415B-A48F-8CD4B3FAB7E8@mi crosoft.com...
                "Mr. Arnold" wrote:
                >>
                >As someone else said, you might not find a VB example, and as a good .Net
                >programmer, you need to know C# and VB. It's not that hard to translate.
                >There is no reason that you can't use the class for an ASP.Net solution.
                >>
                >There is also no reason you couldn't just take the class talked about as
                >is,
                >compile as a C# dll, and set reference to the DLL and use it in your VB
                >project.
                >>
                >http://www.codeproject.com/KB/system/mapnetdrive.aspx
                >>
                >>
                Thank you for the response. I have no problems using C# code; I just
                asked
                that initially because it's what I'm most familiar with. I've come across
                that class before, but the problem is that it requires the password of the
                user I'm mapping a network drive for. I was hoping there was some way I
                could use IIS Windows Authentication or something similar to do this with
                an
                account that has administrative rights, so I wouldn't be required to know
                the
                user's password.
                I don't see why you couldn't use a generic user-id and psw that had admin
                rights, but of course this application should never face the Internet.

                Comment

                • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

                  #9
                  Re: Map network drive for user using VB/ASP.NET

                  "Mr. Arnold" wrote:
                  >
                  I don't see why you couldn't use a generic user-id and psw that had admin
                  rights, but of course this application should never face the Internet.
                  >
                  >
                  That's exactly what I would like to do, but I don't see how that could be
                  done with this class (or other methods I've found). If I were to supply an
                  admin username/password, it would map the drive to that admin user -- I want
                  to perform this task under an admin account, but the drive should actually be
                  mapped for another user.

                  As for doubting the impossibility of doing this without ActiveX, you might
                  be right -- I think the Microsoft MVP may have misunderstood what I was
                  trying to do.

                  Comment

                  • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

                    #10
                    Re: Map network drive for user using VB/ASP.NET

                    "Brian Nicholson" wrote:
                    >
                    That's exactly what I would like to do, but I don't see how that could be
                    done with this class (or other methods I've found). If I were to supply an
                    admin username/password, it would map the drive to that admin user -- I want
                    to perform this task under an admin account, but the drive should actually be
                    mapped for another user.
                    >
                    As for doubting the impossibility of doing this without ActiveX, you might
                    be right -- I think the Microsoft MVP may have misunderstood what I was
                    trying to do.
                    Scratch that -- I originally thought that the username and password were for
                    the destination of the drive mapping, but it makes more sense that the
                    username and password is to simply supply credentials for mapping the drive
                    on the local computer. I guess my question then is how do I get this script
                    to execute on a specified computer other than the web server?

                    Comment

                    • Patrice

                      #11
                      Re: Map network drive for user using VB/ASP.NET

                      IMO your best would be to explain why you are trying to map a drive (i.e. I
                      mean the overall goal not the way you plan to this for now).

                      Do you try to map a drive server side ? I would avoid doing such a thing and
                      would use an UNC drive ? (do you REALLY need a mapped drive ???)

                      Do you try to map a drive client side ? It looks like it would be best
                      suitable to do that from the login script rather than using a web
                      application. If this is to be able to run scripts from a network share they
                      could be best placed on the NETLOGON share etc....

                      Knowing exactly what is the overall goal could raise better suggestions...

                      --
                      Patrice

                      "Brian Nicholson" <BrianNicholson @discussions.mi crosoft.coma écrit dans le
                      message de groupe de discussion :
                      4B7E22F8-D4B3-4C1E-AD5D-C62D4447744D@mi crosoft.com...
                      "Mr. Arnold" wrote:
                      >
                      >>
                      >I don't see why you couldn't use a generic user-id and psw that had admin
                      >rights, but of course this application should never face the Internet.
                      >>
                      >>
                      >
                      That's exactly what I would like to do, but I don't see how that could be
                      done with this class (or other methods I've found). If I were to supply
                      an
                      admin username/password, it would map the drive to that admin user -- I
                      want
                      to perform this task under an admin account, but the drive should actually
                      be
                      mapped for another user.
                      >
                      As for doubting the impossibility of doing this without ActiveX, you might
                      be right -- I think the Microsoft MVP may have misunderstood what I was
                      trying to do.

                      Comment

                      • Patrice

                        #12
                        Re: Map network drive for user using VB/ASP.NET

                        You would have to send a client side script inside your web page. This
                        script would use the WScript.Network object to map the drive. You'll need
                        also to alter security settings - possibly done by your admin at an
                        entreprise level - to be able to do that (for example adding your intranet
                        site to the trusted sites).

                        Not sure why you need to do that but my personal preference would be to have
                        the admin team creating a mapping strategy and have the network drives
                        mapped automatically using the logon script (possibly depending about the
                        group in which the user is). Try for example


                        As said earlier you may want to elaborate about your final goal...


                        --
                        Patrice

                        "Brian Nicholson" <BrianNicholson @discussions.mi crosoft.coma écrit dans le
                        message de groupe de discussion :
                        5F0F2AA9-0E78-46D2-8DFD-C4F8DDD3E9EE@mi crosoft.com...
                        "Brian Nicholson" wrote:
                        >
                        >>
                        >That's exactly what I would like to do, but I don't see how that could be
                        >done with this class (or other methods I've found). If I were to supply
                        >an
                        >admin username/password, it would map the drive to that admin user -- I
                        >want
                        >to perform this task under an admin account, but the drive should
                        >actually be
                        >mapped for another user.
                        >>
                        >As for doubting the impossibility of doing this without ActiveX, you
                        >might
                        >be right -- I think the Microsoft MVP may have misunderstood what I was
                        >trying to do.
                        >
                        Scratch that -- I originally thought that the username and password were
                        for
                        the destination of the drive mapping, but it makes more sense that the
                        username and password is to simply supply credentials for mapping the
                        drive
                        on the local computer. I guess my question then is how do I get this
                        script
                        to execute on a specified computer other than the web server?

                        Comment

                        • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

                          #13
                          Re: Map network drive for user using VB/ASP.NET

                          Good question -- as far as I know, it's a matter of convenience. Users
                          constantly access the same network folders, and it's a pain to have to browse
                          to the folder each time something needs to be saved/accessed. Users call in
                          requesting to have a certain directory mapped as a drive, so it would be
                          convenient to have a web app that can do this for us.

                          "Patrice" wrote:
                          IMO your best would be to explain why you are trying to map a drive (i.e. I
                          mean the overall goal not the way you plan to this for now).
                          >
                          Do you try to map a drive server side ? I would avoid doing such a thing and
                          would use an UNC drive ? (do you REALLY need a mapped drive ???)
                          >
                          Do you try to map a drive client side ? It looks like it would be best
                          suitable to do that from the login script rather than using a web
                          application. If this is to be able to run scripts from a network share they
                          could be best placed on the NETLOGON share etc....
                          >
                          Knowing exactly what is the overall goal could raise better suggestions...
                          >
                          --
                          Patrice
                          >
                          "Brian Nicholson" <BrianNicholson @discussions.mi crosoft.coma crit dans le
                          message de groupe de discussion :
                          4B7E22F8-D4B3-4C1E-AD5D-C62D4447744D@mi crosoft.com...
                          "Mr. Arnold" wrote:
                          >
                          I don't see why you couldn't use a generic user-id and psw that had admin
                          rights, but of course this application should never face the Internet.
                          >
                          >
                          That's exactly what I would like to do, but I don't see how that could be
                          done with this class (or other methods I've found). If I were to supply
                          an
                          admin username/password, it would map the drive to that admin user -- I
                          want
                          to perform this task under an admin account, but the drive should actually
                          be
                          mapped for another user.

                          As for doubting the impossibility of doing this without ActiveX, you might
                          be right -- I think the Microsoft MVP may have misunderstood what I was
                          trying to do.
                          >
                          >

                          Comment

                          • rowe_newsgroups

                            #14
                            Re: Map network drive for user using VB/ASP.NET

                            On Jun 30, 12:21 pm, Brian Nicholson
                            <BrianNichol... @discussions.mi crosoft.comwrot e:
                            "Brian Nicholson" wrote:
                            >
                            That's exactly what I would like to do, but I don't see how that could be
                            done with this class (or other methods I've found).  If I were to supply an
                            admin username/password, it would map the drive to that admin user -- I want
                            to perform this task under an admin account, but the drive should actually be
                            mapped for another user.
                            >
                            As for doubting the impossibility of doing this without ActiveX, you might
                            be right -- I think the Microsoft MVP may have misunderstood what I was
                            trying to do.
                            >
                            Scratch that -- I originally thought that the username and password were for
                            the destination of the drive mapping, but it makes more sense that the
                            username and password is to simply supply credentials for mapping the drive
                            on the local computer.  I guess my question then is how do I get this script
                            to execute on a specified computer other than the web server?
                            To me, the easiest solutions would be to write a small Window's app
                            that maps the network drive and then publish that application to your
                            website. Then, using ClickOnce deployment, all a user would have to do
                            is click the link, select 'Run', and then the window's app would run
                            and map the drive. The nice thing is that since it's a Window's app,
                            you can easily run impersonation and run the "map drive" commands
                            under an admin account, invisible to the user.

                            Thanks,

                            Seth Rowe [MVP]

                            Comment

                            • =?Utf-8?B?QnJpYW4gTmljaG9sc29u?=

                              #15
                              Re: Map network drive for user using VB/ASP.NET



                              "rowe_newsgroup s" wrote:
                              >
                              To me, the easiest solutions would be to write a small Window's app
                              that maps the network drive and then publish that application to your
                              website. Then, using ClickOnce deployment, all a user would have to do
                              is click the link, select 'Run', and then the window's app would run
                              and map the drive. The nice thing is that since it's a Window's app,
                              you can easily run impersonation and run the "map drive" commands
                              under an admin account, invisible to the user.
                              >
                              Thanks,
                              >
                              Seth Rowe [MVP]

                              >
                              That sounds pretty similar to what I'd like to do, but the part I'm stuck on
                              is actually creating the app that maps the drive. So far, I've been
                              unsuccessful finding any kind of method or class that can map a drive
                              *remotely*...if such a thing even exists.

                              Comment

                              Working...