Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to access a password protected UNC address?

How to access a password protected UNC address?

Scheduled Pinned Locked Moved C#
questioncsharptutorial
8 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zishan Haider
    wrote on last edited by
    #1

    Hello, I am accessing a shared file through UNC address over LAN. Whenever I do that, the windows login prompt appears. I need to bypass this prompt though C# code. How can I do it? Regards, Zishan

    N D 2 Replies Last reply
    0
    • Z Zishan Haider

      Hello, I am accessing a shared file through UNC address over LAN. Whenever I do that, the windows login prompt appears. I need to bypass this prompt though C# code. How can I do it? Regards, Zishan

      N Offline
      N Offline
      narendrakumarp
      wrote on last edited by
      #2

      \\server-name\directory\filename Just try with this, if possible u can get it. please help me

      Z 1 Reply Last reply
      0
      • N narendrakumarp

        \\server-name\directory\filename Just try with this, if possible u can get it. please help me

        Z Offline
        Z Offline
        Zishan Haider
        wrote on last edited by
        #3

        Thanks for the reply.. yes right but then I try to access file like this.. a windows login prompt appears and I have to enter username and password manually.. I want this manual thingi to be handled by code. Some way to enter this Windows Authentication. Regards Zishan

        J 1 Reply Last reply
        0
        • Z Zishan Haider

          Thanks for the reply.. yes right but then I try to access file like this.. a windows login prompt appears and I have to enter username and password manually.. I want this manual thingi to be handled by code. Some way to enter this Windows Authentication. Regards Zishan

          J Offline
          J Offline
          Judah Gabriel Himango
          wrote on last edited by
          #4

          Have you tried using System.Diagnostics.ProcessStartInfo? With that, you can supply a user name & password through code, but I don't know if this will work for UNC shares.

          1 Reply Last reply
          0
          • Z Zishan Haider

            Hello, I am accessing a shared file through UNC address over LAN. Whenever I do that, the windows login prompt appears. I need to bypass this prompt though C# code. How can I do it? Regards, Zishan

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            You can try Judah's suggestion. I don't know if it'll work either. But, if it doesn't, a workaround I know of would be to temporarily map a drive to the share. You can most definately supply the username and password to that. But, to clarify, there is NO WAY to get around that login box. The machine your connecting to wants to know who is trying to get into that share. That target machine doesn't trust the credentials that your app is running under. There is simply no way of getting around that. But, if the credentials are supplied using a different method, that box won't show up. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            Z 1 Reply Last reply
            0
            • D Dave Kreskowiak

              You can try Judah's suggestion. I don't know if it'll work either. But, if it doesn't, a workaround I know of would be to temporarily map a drive to the share. You can most definately supply the username and password to that. But, to clarify, there is NO WAY to get around that login box. The machine your connecting to wants to know who is trying to get into that share. That target machine doesn't trust the credentials that your app is running under. There is simply no way of getting around that. But, if the credentials are supplied using a different method, that box won't show up. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              Z Offline
              Z Offline
              Zishan Haider
              wrote on last edited by
              #6

              Thanks both of you.. I am off from work now.. will try Judah's suggestion tomorrow. Dave what credentials are you talking about.. can you please elaborate a bit more.. Let me be more precise. I have an application running on Windows XP Professional trying to access a shared file located on a network drive which is running Windows Server 2000. What's that "other method" :confused: Can you elaborate? Thanks Zishan

              D 1 Reply Last reply
              0
              • Z Zishan Haider

                Thanks both of you.. I am off from work now.. will try Judah's suggestion tomorrow. Dave what credentials are you talking about.. can you please elaborate a bit more.. Let me be more precise. I have an application running on Windows XP Professional trying to access a shared file located on a network drive which is running Windows Server 2000. What's that "other method" :confused: Can you elaborate? Thanks Zishan

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                Zishan Haider wrote:

                what credentials are you talking about

                The credentials you used when you logged into Windows on your machine...Username and password. When you try to connect to another Windows machine, those credentials are sent to the remote machine. If that machine isn't a member of the same domain (if you have one!) as your machine, then it has to rely on its own user accounts to authenticate you. If your username doesn't exist on the remote machine, it'll ask you for an account and password that it knows about, because it doesn't trust the account information it's getting from your machine. Now, you only have to log into a remote machine once and it'll remember who you are for as long as you are logged into your machine. There are many different ways to get an authenticated connection to a remote Windows machine. The most common is mapping a drive letter to a share on the remote machine. You have to supply a username and password to the remote machine if it doesn't trust you. Since you can't just connect to a remote share without first authenticating to the remote machine, you need to authenticate an account with the remote machine. You can't do that by just connecting to a remote share. There's no way to enter the account information. But, you CAN do it through code if your code maps a drive to the share first. You have to supply the function For example...[^] RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                Z 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Zishan Haider wrote:

                  what credentials are you talking about

                  The credentials you used when you logged into Windows on your machine...Username and password. When you try to connect to another Windows machine, those credentials are sent to the remote machine. If that machine isn't a member of the same domain (if you have one!) as your machine, then it has to rely on its own user accounts to authenticate you. If your username doesn't exist on the remote machine, it'll ask you for an account and password that it knows about, because it doesn't trust the account information it's getting from your machine. Now, you only have to log into a remote machine once and it'll remember who you are for as long as you are logged into your machine. There are many different ways to get an authenticated connection to a remote Windows machine. The most common is mapping a drive letter to a share on the remote machine. You have to supply a username and password to the remote machine if it doesn't trust you. Since you can't just connect to a remote share without first authenticating to the remote machine, you need to authenticate an account with the remote machine. You can't do that by just connecting to a remote share. There's no way to enter the account information. But, you CAN do it through code if your code maps a drive to the share first. You have to supply the function For example...[^] RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                  Z Offline
                  Z Offline
                  Zishan Haider
                  wrote on last edited by
                  #8

                  Hey Dave.. Thanks a lot for your support.. it just solves my problem :-D

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups