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. Visual Basic
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved Visual Basic
19 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.
  • H hitesh sojitra

    [Message Deleted]

    J Offline
    J Offline
    John_Adams
    wrote on last edited by
    #2

    Hi Hitesh, Please the following code snippet. -------------------------------------------------------------------------- BEGIN CODE Dim dirInfo As New DirectoryInfo("C:\Temp") ' Get a DirectorySecurity object that represents the ' current security settings. Dim dSecurity As DirectorySecurity = dirInfo.GetAccessControl() ' Add the FileSystemAccessRule to the security settings. dSecurity.AddAccessRule(New FileSystemAccessRule("ShanmuganathanR\Shan", FileSystemRights.Delete, AccessControlType.Deny)) ' Set the new access settings. dirInfo.SetAccessControl(dSecurity) END CODE -------------------------------------------------------------------------- Hope this helps :).

    Regards, John Adams ComponentOne LLC

    H 2 Replies Last reply
    0
    • J John_Adams

      Hi Hitesh, Please the following code snippet. -------------------------------------------------------------------------- BEGIN CODE Dim dirInfo As New DirectoryInfo("C:\Temp") ' Get a DirectorySecurity object that represents the ' current security settings. Dim dSecurity As DirectorySecurity = dirInfo.GetAccessControl() ' Add the FileSystemAccessRule to the security settings. dSecurity.AddAccessRule(New FileSystemAccessRule("ShanmuganathanR\Shan", FileSystemRights.Delete, AccessControlType.Deny)) ' Set the new access settings. dirInfo.SetAccessControl(dSecurity) END CODE -------------------------------------------------------------------------- Hope this helps :).

      Regards, John Adams ComponentOne LLC

      H Offline
      H Offline
      hitesh sojitra
      wrote on last edited by
      #3

      Thanks it works... :) Is there any API for retriving domainname/user. :)

      Hitesh sojitra

      J 1 Reply Last reply
      0
      • J John_Adams

        Hi Hitesh, Please the following code snippet. -------------------------------------------------------------------------- BEGIN CODE Dim dirInfo As New DirectoryInfo("C:\Temp") ' Get a DirectorySecurity object that represents the ' current security settings. Dim dSecurity As DirectorySecurity = dirInfo.GetAccessControl() ' Add the FileSystemAccessRule to the security settings. dSecurity.AddAccessRule(New FileSystemAccessRule("ShanmuganathanR\Shan", FileSystemRights.Delete, AccessControlType.Deny)) ' Set the new access settings. dirInfo.SetAccessControl(dSecurity) END CODE -------------------------------------------------------------------------- Hope this helps :).

        Regards, John Adams ComponentOne LLC

        H Offline
        H Offline
        hitesh sojitra
        wrote on last edited by
        #4

        i observe that FileSystemRights once changed cant not be reset programmatically through the same APIs. dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.FullControl, AccessControlType.Deny)) the follwing doesnt seem to work once the rights are set to AccessControlType.Deny. dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Read, AccessControlType.Allow)) pls help..

        Hitesh sojitra

        C D 2 Replies Last reply
        0
        • H hitesh sojitra

          i observe that FileSystemRights once changed cant not be reset programmatically through the same APIs. dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.FullControl, AccessControlType.Deny)) the follwing doesnt seem to work once the rights are set to AccessControlType.Deny. dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Read, AccessControlType.Allow)) pls help..

          Hitesh sojitra

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

          I guess perhaps you lose the right to set it to allow, as the user you're logged in as, or running as ?

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          • H hitesh sojitra

            i observe that FileSystemRights once changed cant not be reset programmatically through the same APIs. dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.FullControl, AccessControlType.Deny)) the follwing doesnt seem to work once the rights are set to AccessControlType.Deny. dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Read, AccessControlType.Allow)) pls help..

            Hitesh sojitra

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

            Yeah, once the user that runs this code, they give up all of their permissions to modify the access rules. That same user cannot then get it back because they no longer have the permissions to set the access rules.

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

            H 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Yeah, once the user that runs this code, they give up all of their permissions to modify the access rules. That same user cannot then get it back because they no longer have the permissions to set the access rules.

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

              H Offline
              H Offline
              hitesh sojitra
              wrote on last edited by
              #7

              ya i gatting same problem.. than what is solution to enable it by code?

              Hitesh sojitra

              C 1 Reply Last reply
              0
              • H hitesh sojitra

                ya i gatting same problem.. than what is solution to enable it by code?

                Hitesh sojitra

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

                There is none. You said 'don't let me edit this'. Now you can't edit it.

                Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                H 1 Reply Last reply
                0
                • C Christian Graus

                  There is none. You said 'don't let me edit this'. Now you can't edit it.

                  Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  H Offline
                  H Offline
                  hitesh sojitra
                  wrote on last edited by
                  #9

                  If i set individual permission instead of FullControl than it possible to enable by .Allow option ?

                  Hitesh sojitra

                  C 1 Reply Last reply
                  0
                  • H hitesh sojitra

                    If i set individual permission instead of FullControl than it possible to enable by .Allow option ?

                    Hitesh sojitra

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

                    I guess try it and see.

                    Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                    H 1 Reply Last reply
                    0
                    • C Christian Graus

                      I guess try it and see.

                      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                      H Offline
                      H Offline
                      hitesh sojitra
                      wrote on last edited by
                      #11

                      i tried but not a single permission could be enabled by .Allow Option

                      Hitesh sojitra

                      D 1 Reply Last reply
                      0
                      • H hitesh sojitra

                        i tried but not a single permission could be enabled by .Allow Option

                        Hitesh sojitra

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

                        You're OBVIOUSLY going to have to use an admin account to grant the permissions back to that user. Then you can go back as that user and try your code again. Please tell me you know how permissions and Windows Security works before you attempt to write code that manipulates it?? BTW: What you're doing is a complete waste of time. You're really not proecting anything by allowing the user to manipulate access rights. There is absolutely nothing stopping the user from resetting the permissions directly on these files/folders from Explorer. Please keep in mind that any code a user launches runs AS the user. There is no special permissions that code gets over and above the permissions the user has who launched it.

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

                        H 1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          You're OBVIOUSLY going to have to use an admin account to grant the permissions back to that user. Then you can go back as that user and try your code again. Please tell me you know how permissions and Windows Security works before you attempt to write code that manipulates it?? BTW: What you're doing is a complete waste of time. You're really not proecting anything by allowing the user to manipulate access rights. There is absolutely nothing stopping the user from resetting the permissions directly on these files/folders from Explorer. Please keep in mind that any code a user launches runs AS the user. There is no special permissions that code gets over and above the permissions the user has who launched it.

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

                          H Offline
                          H Offline
                          hitesh sojitra
                          wrote on last edited by
                          #13

                          [Message Deleted]

                          H D 2 Replies Last reply
                          0
                          • H hitesh sojitra

                            [Message Deleted]

                            H Offline
                            H Offline
                            hitesh sojitra
                            wrote on last edited by
                            #14

                            first i m using this code to Deny permission dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Write, AccessControlType.Deny)) AND To enable it i Use this code dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Write, AccessControlType.Allow)) is it right way ?

                            Hitesh sojitra

                            H 1 Reply Last reply
                            0
                            • H hitesh sojitra

                              [Message Deleted]

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

                              hitesh sojitra wrote:

                              but i don't know in much detail how windows security works ? he

                              Sorry, this is a topic that is so large, it's covered by entire books. A few forum posts is not going to cover it. Click[^]

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

                              1 Reply Last reply
                              0
                              • H hitesh sojitra

                                first i m using this code to Deny permission dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Write, AccessControlType.Deny)) AND To enable it i Use this code dSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule("cybergindia\hitesh", FileSystemRights.Write, AccessControlType.Allow)) is it right way ?

                                Hitesh sojitra

                                H Offline
                                H Offline
                                hitesh sojitra
                                wrote on last edited by
                                #16

                                ok So sir just you guide me how to enable individual permission of folder/file

                                Hitesh sojitra

                                D 1 Reply Last reply
                                0
                                • H hitesh sojitra

                                  ok So sir just you guide me how to enable individual permission of folder/file

                                  Hitesh sojitra

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

                                  You're already doing it the correct way. It's your lack of understanding about how permissions work that's going against you.

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

                                  H 1 Reply Last reply
                                  0
                                  • H hitesh sojitra

                                    Thanks it works... :) Is there any API for retriving domainname/user. :)

                                    Hitesh sojitra

                                    J Offline
                                    J Offline
                                    John_Adams
                                    wrote on last edited by
                                    #18

                                    Hi Hitesh, It is good to hear that my response was helpful. Well, I am not aware of any such API's however, you may try to explore the System.Security namespace for more feature and functionality. Hope this helps.

                                    Regards, John Adams ComponentOne LLC

                                    1 Reply Last reply
                                    0
                                    • D Dave Kreskowiak

                                      You're already doing it the correct way. It's your lack of understanding about how permissions work that's going against you.

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

                                      H Offline
                                      H Offline
                                      hitesh sojitra
                                      wrote on last edited by
                                      #19

                                      ok Thank for help will try and let u know again ......

                                      Hitesh sojitra

                                      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