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. Windows API
  4. Creating directory with full access permissions in Vista using VC++

Creating directory with full access permissions in Vista using VC++

Scheduled Pinned Locked Moved Windows API
c++
5 Posts 3 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.
  • V Offline
    V Offline
    V K 2
    wrote on last edited by
    #1

    I want to create a directory giving full access permissions to every user ( Admin and Non Admin). Can I have a sample code . Thanks...

    M 1 Reply Last reply
    0
    • V V K 2

      I want to create a directory giving full access permissions to every user ( Admin and Non Admin). Can I have a sample code . Thanks...

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Maybe this?[^]

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      V 1 Reply Last reply
      0
      • M Mark Salsbery

        Maybe this?[^]

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        V Offline
        V Offline
        V K 2
        wrote on last edited by
        #3

        Thanks... I tried this.. It works in win2003 ,but not in Vista.. I need same functionality in Vista.

        M H 2 Replies Last reply
        0
        • V V K 2

          Thanks... I tried this.. It works in win2003 ,but not in Vista.. I need same functionality in Vista.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Didn't work on Vista? I tried the first code at that link (on Vista):

          SECURITY_ATTRIBUTES sa;
          SECURITY_DESCRIPTOR sd;

          ::InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
          ::SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
          ::SetSecurityDescriptorGroup(&sd,NULL, FALSE );
          ::SetSecurityDescriptorSacl(&sd, FALSE, NULL, FALSE );

          sa.nLength = sizeof(SECURITY_ATTRIBUTES);
          sa.lpSecurityDescriptor = &sd;
          sa.bInheritHandle = TRUE;

          ::CreateDirectory( _T("e:\\testcreatedirectory"), &sa);

          That worked fine, but the directory can be taken over by anyone. This article (Creating a DACL[^]) has sample code that works on Vista as well:

          SECURITY_ATTRIBUTES sa;
          sa.nLength = sizeof(SECURITY_ATTRIBUTES);
          sa.bInheritHandle = FALSE;

          TCHAR * szSD = TEXT("D:") // Discretionary ACL
          TEXT("(D;OICI;GA;;;BG)") // Deny access to built-in guests
          TEXT("(D;OICI;GA;;;AN)") // Deny access to anonymous logon
          //TEXT("(A;OICI;GRGWGX;;;AU)") // Allow read/write/execute to authenticated users
          //TEXT("(A;OICI;GA;;;BA)"); // Allow full control to administrators
          TEXT("(A;OICI;GA;;;AU)"); // Allow full control to authenticated users

          if (::ConvertStringSecurityDescriptorToSecurityDescriptor(szSD,
          SDDL_REVISION_1,
          &sa.lpSecurityDescriptor,
          NULL))
          {
          ::CreateDirectory( _T("e:\\testcreatedirectory"), &sa);
          ::LocalFree(sa.lpSecurityDescriptor)
          }

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          modified on Wednesday, September 17, 2008 4:19 PM

          1 Reply Last reply
          0
          • V V K 2

            Thanks... I tried this.. It works in win2003 ,but not in Vista.. I need same functionality in Vista.

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            It seems Mark's code must be work on the vista. :)

            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