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 protected-pass folder

how to access protected-pass folder

Scheduled Pinned Locked Moved C#
questioncsharpwinformssecurityxml
11 Posts 4 Posters 0 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.
  • A alex almeida

    Hello everybody! I've a trouble and I can't solve :-( I've a PC with a local login/password shared folder and I need authenticate this user across winforms application to write a xml file. The question is, how do I authenticate this user? This user doesn't in AD group (is just a local user in machine).I need to do authentication manually. Somebody knows? Tks 4all!

    M Offline
    M Offline
    mikker_123
    wrote on last edited by
    #2

    LOL :)... I asked same thing but for certificates... and googling for you solution I think I found mine. Anyways... if you wish to control permissions use following code (example is for directory): private static void GiveAccessToFolder() { string path = @"d:\testFolder\"; DirectorySecurity ds = Directory.GetAccessControl(path); ds.AddAccessRule(new FileSystemAccessRule("ARCHITECT\\testuser", FileSystemRights.FullControl, AccessControlType.Allow)); Directory.SetAccessControl(path, ds); } You can find more examples over here. Enjoy friend!

    A 1 Reply Last reply
    0
    • A alex almeida

      Hello everybody! I've a trouble and I can't solve :-( I've a PC with a local login/password shared folder and I need authenticate this user across winforms application to write a xml file. The question is, how do I authenticate this user? This user doesn't in AD group (is just a local user in machine).I need to do authentication manually. Somebody knows? Tks 4all!

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

      NTFS doesn't support password protected folders. What kind of "shared folder" is this?? A password protected .ZIP file?

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      C A 2 Replies Last reply
      0
      • D Dave Kreskowiak

        NTFS doesn't support password protected folders. What kind of "shared folder" is this?? A password protected .ZIP file?

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #4

        I assume he means the folder is a network share, and he needs a username/password to access it.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        D 1 Reply Last reply
        0
        • C Christian Graus

          I assume he means the folder is a network share, and he needs a username/password to access it.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

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

          I was thinking the same thing, but I didn't want to assume. You know what happens when we assume around here! :laugh:

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            I was thinking the same thing, but I didn't want to assume. You know what happens when we assume around here! :laugh:

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            M Offline
            M Offline
            mikker_123
            wrote on last edited by
            #6

            Cmon... assume some solution to my certificate problem ;)

            D 1 Reply Last reply
            0
            • M mikker_123

              Cmon... assume some solution to my certificate problem ;)

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

              I didn't answer because it's outside my relm of experience and I've run out of time to try to setup a test environment for this.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              1 Reply Last reply
              0
              • M mikker_123

                LOL :)... I asked same thing but for certificates... and googling for you solution I think I found mine. Anyways... if you wish to control permissions use following code (example is for directory): private static void GiveAccessToFolder() { string path = @"d:\testFolder\"; DirectorySecurity ds = Directory.GetAccessControl(path); ds.AddAccessRule(new FileSystemAccessRule("ARCHITECT\\testuser", FileSystemRights.FullControl, AccessControlType.Allow)); Directory.SetAccessControl(path, ds); } You can find more examples over here. Enjoy friend!

                A Offline
                A Offline
                alex almeida
                wrote on last edited by
                #8

                Hello, tks for help. I tried to use this code, but I got a exception at this command DirectorySecurity ds = Directory.GetAccessControl(path); with message "Attempted to perform an unauthorized operation" Almost there..heheheeh

                1 Reply Last reply
                0
                • D Dave Kreskowiak

                  NTFS doesn't support password protected folders. What kind of "shared folder" is this?? A password protected .ZIP file?

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007

                  A Offline
                  A Offline
                  alex almeida
                  wrote on last edited by
                  #9

                  Well I created a shared folder, and I created also a user in the same machine (aka Maq048) the user that was created is xmlowner, then I've a Maq048\xmlowner user. In the folder I set permission to Maq048\xmlowner (full control), and now I want access this folder across network and save a file. But I don't know how to authenticate this user by C# application.

                  M 1 Reply Last reply
                  0
                  • A alex almeida

                    Well I created a shared folder, and I created also a user in the same machine (aka Maq048) the user that was created is xmlowner, then I've a Maq048\xmlowner user. In the folder I set permission to Maq048\xmlowner (full control), and now I want access this folder across network and save a file. But I don't know how to authenticate this user by C# application.

                    M Offline
                    M Offline
                    mikker_123
                    wrote on last edited by
                    #10

                    You are looking for something like this?

                    A 1 Reply Last reply
                    0
                    • M mikker_123

                      You are looking for something like this?

                      A Offline
                      A Offline
                      alex almeida
                      wrote on last edited by
                      #11

                      Yeah, something like this.. I created one user at pc01 and the same user at PC02 I impersonate my user at PC02 then I obtained to have access the protected folder in PC02 Tks 4all!!!! [: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