473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Add "Everyone" Group permission to access a file

JimWu
14
As title, I'd like to add a "Everyone" group to a file and give this account a full control right.

I have try to use FileSecurity class to add a account, ASPNET ,for example.

code as follow:
Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.      AddFileSecurity(@"c:\TestACL.txt", "ASPNET", FileSystemRights.FullControl, AccessControlType.Allow);
  4. }
  5. catch(Exception e){
  6.  
  7. }
  8.  
  9.   public static void AddFileSecurity(string filepath, string account, FileSystemRights right, AccessControlType controlType) 
  10. {
  11.  
  12.       FileSecurity filesec = File.GetAccessControl(filepath);
  13.       filesec.AddAccessRule(new FileSystemAccessRule(account, right, controlType));
  14.             File.SetAccessControl(filepath, filesec);
  15.  
  16.  
Now, I'd like to add another account "Everyone", instead of "ASPNET" above code, but it's not work.

Have anyone get idea or can tell me this question.

Think you,

Jim.
Aug 14 '07 #1
4 10956
spacix
12
The reason you can't do this is a matter of NTFS permissions. The "Everyone" you can see in file permissions tab on a file/folder on a NTFS file system is a "Built-in security principal." It is assigned to every group, user, and other "Built-in security principals." (Other Examples: CREATOR OWNER, SYSTEM, SERVICE, an so forth, some of these have higher than administrator privileges)

These aren't physical users (such as Administrator) or groups, and I'm fairly sure you need to be an administrator/running with administrator privileges, to edit/change file permissions to these "Built-in security principals."

You are running this in ASP.NET from what I pickup from you post, so the application trying to set the security of the file is from a limited account (for VERY good security reasons, I don't suggest changing it) that isn't allowed to give access rights to a "Built-in security principal." If it was allowed full control a file could be uploaded and even executed with administrator privileges!; which is very very bad.
Aug 14 '07 #2
JimWu
14
Thinks for ur kindly answer.
Now, I have another problem to Add permission on a folder.
Code (cs):

try{
AddDirectorySecurity(@"c:\Upload", "USERS", FileSystemRights.FullControl, AccessControlType.Allow);
}
catch(Exception e){

}
public static void AddDirectorySecurity(string folderName, string account, FileSystemRights rights, AccessControlType controlType) {

DirectoryInfo dir = new DirectoryInfo(folderName);
DirectorySecurity sec = dir.GetAccessControl();
sec.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));
dir.SetAccessControl(sec);

}

After that, the folder "Upload" is added successfully permission,I check this folder's, Upload, properties, and then I see the this folder permission but I dont know why this folder's permission is only add a "sepcial Permissions" list, checked , on this account "USERS" for the upload folder.

My purpose is add FullControl permission or others single permission,for example, Read, to USERS account on folder.

Do anyone have a good solution to answer this question.

Thank you for help.

Jim.
Aug 15 '07 #3
spacix
12
Most likely cause of this "error"/problem is that the permissions are only applying to one or two of the following; but not all of them which is called "full control."
  • This folder
  • subfolders
  • files

You might have better luck making a new folder somewhere else (sorta like a sandbox for your application; and hopefully on a different drive) and setting the permissions to not to inherit (yet click to copy them) then allow "higher" access rights for the ASP.NET user. maybe even make it the "CREATOR OWNER" of the file and set the "CREATOR OWNER" object's access rights down. Though you should limit execute for the whole folder and keep your scripts elsewhere, or in a sibling directory.

After this your new folders (created with inherit) would be able to have the same access rights without setting permissions. This would be your best bet if your going to be making a lot of these...

Thinks for ur kindly answer.
Now, I have another problem to Add permission on a folder.
Code (cs):

try{
AddDirectorySecurity(@"c:\Upload", "USERS", FileSystemRights.FullControl, AccessControlType.Allow);
}
catch(Exception e){

}
public static void AddDirectorySecurity(string folderName, string account, FileSystemRights rights, AccessControlType controlType) {

DirectoryInfo dir = new DirectoryInfo(folderName);
DirectorySecurity sec = dir.GetAccessControl();
sec.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));
dir.SetAccessControl(sec);

}

After that, the folder "Upload" is added successfully permission,I check this folder's, Upload, properties, and then I see the this folder permission but I dont know why this folder's permission is only add a "sepcial Permissions" list, checked , on this account "USERS" for the upload folder.

My purpose is add FullControl permission or others single permission,for example, Read, to USERS account on folder.

Do anyone have a good solution to answer this question.

Thank you for help.

Jim.
Aug 15 '07 #4
JimWu
14
Kindly spacix ,thank you for your kindly answer to me.

I obtain some many basic concepts of NTFS permissions from you.

Now, I am already find the answer to solve my problem.

Thank you very much.

Jim




Most likely cause of this "error"/problem is that the permissions are only applying to one or two of the following; but not all of them which is called "full control."
  • This folder
  • subfolders
  • files

You might have better luck making a new folder somewhere else (sorta like a sandbox for your application; and hopefully on a different drive) and setting the permissions to not to inherit (yet click to copy them) then allow "higher" access rights for the ASP.NET user. maybe even make it the "CREATOR OWNER" of the file and set the "CREATOR OWNER" object's access rights down. Though you should limit execute for the whole folder and keep your scripts elsewhere, or in a sibling directory.

After this your new folders (created with inherit) would be able to have the same access rights without setting permissions. This would be your best bet if your going to be making a lot of these...
Aug 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
5
by: Peter Verhelst | last post by:
Hello, Currently I am running an Access database on a windows WTS server, running Microsoft Windows 2000 server 5.00.2195 Service Pack 3. This database should be accessible for everybody in our...
4
by: (Pete Cresswell) | last post by:
I would argue that it is not. JET is a desktop DB engine. Sybase is a database Oracle is a database DB2 is a database. VB 6 is a front-end development tool. PowerBuilder is a front-end...
9
by: Clinton Frankland | last post by:
Hi, On a Windows 2000 Server when attempting to use System.IO.Directory.CreateDirectory(string.concat(Server.MapPath(""), "\verify")) I receive a System.IO.DirectoryNotFoundException error:...
1
by: Praveen | last post by:
Here is an easy issue to reproduce: 1) Create a new project. 2) Drop a DataGrid control into the Page. Also drop a OleDbDataAdapter into the page. 3) Select "Configure Data Adapter..." and pick...
0
by: Christian Blackburn | last post by:
Hi Gang, I've written my installer and there's quite a few things I can't figure out how to do with it :). This was the same reason I started using InnoSetup with VB6 (works great by the way...
0
by: Michael Fitzpatrick | last post by:
I have a .NET application with an installer. The customer wants the install page with the "Everyone" or "Just Me" selection to default to "Everyone". Presently it defaults to "Just Me". Any hints...
4
by: Ronald S. Cook | last post by:
I created an MSI install for a Windows app I wrote. When installing, however, it defaults to install for "Just Me" instead of "Eveveryone" (meaning anyone who uses this computer). I would like...
1
by: ImageAnalyst | last post by:
Yay!!! They fixed this for VS2005. You can now set the default installation to be "Everyone" instead of "Just Me" and you can control whether you even want those radio button installed in your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.