[Message Deleted]
-
[Message Deleted]
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
-
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
Thanks it works... :) Is there any API for retriving domainname/user. :)
Hitesh sojitra
-
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
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
-
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
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 )
-
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
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 -
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, 2008ya i gatting same problem.. than what is solution to enable it by code?
Hitesh sojitra
-
ya i gatting same problem.. than what is solution to enable it by code?
Hitesh sojitra
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 )
-
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 )
If i set individual permission instead of FullControl than it possible to enable by .Allow option ?
Hitesh sojitra
-
If i set individual permission instead of FullControl than it possible to enable by .Allow option ?
Hitesh sojitra
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 )
-
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 )
i tried but not a single permission could be enabled by .Allow Option
Hitesh sojitra
-
i tried but not a single permission could be enabled by .Allow Option
Hitesh sojitra
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 -
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[Message Deleted]
-
[Message Deleted]
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
-
[Message Deleted]
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 -
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
ok So sir just you guide me how to enable individual permission of folder/file
Hitesh sojitra
-
ok So sir just you guide me how to enable individual permission of folder/file
Hitesh sojitra
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 -
Thanks it works... :) Is there any API for retriving domainname/user. :)
Hitesh sojitra
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
-
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, 2008ok Thank for help will try and let u know again ......
Hitesh sojitra