473,746 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add "Everyone" Group permission to access a file

JimWu
14 New Member
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 10994
spacix
12 New Member
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 New Member
Thinks for ur kindly answer.
Now, I have another problem to Add permission on a folder.
Code (cs):

try{
AddDirectorySec urity(@"c:\Uplo ad", "USERS", FileSystemRight s.FullControl, AccessControlTy pe.Allow);
}
catch(Exception e){

}
public static void AddDirectorySec urity(string folderName, string account, FileSystemRight s rights, AccessControlTy pe controlType) {

DirectoryInfo dir = new DirectoryInfo(f olderName);
DirectorySecuri ty sec = dir.GetAccessCo ntrol();
sec.AddAccessRu le(new FileSystemAcces sRule(account, rights, controlType));
dir.SetAccessCo ntrol(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 New Member
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{
AddDirectorySec urity(@"c:\Uplo ad", "USERS", FileSystemRight s.FullControl, AccessControlTy pe.Allow);
}
catch(Exception e){

}
public static void AddDirectorySec urity(string folderName, string account, FileSystemRight s rights, AccessControlTy pe controlType) {

DirectoryInfo dir = new DirectoryInfo(f olderName);
DirectorySecuri ty sec = dir.GetAccessCo ntrol();
sec.AddAccessRu le(new FileSystemAcces sRule(account, rights, controlType));
dir.SetAccessCo ntrol(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 New Member
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
5120
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 relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these...
5
2651
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 network, so for the time being, I have changed the permission for the .mdb file to Everone -> Full control (I know this is not professional, but I'll sort out the security issues later). When this database is opened, and closed again, it is...
4
2312
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 development tool. MS Access is a front end devlopment tool.
9
13743
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: Could not find a part of the path "D:\". The full path is "D:\hshome\clinton\test.gotchasoft.com\verify" The web is running using impersonation as a user on the local machine.
1
1293
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 the NWind.mdb (for example). Go ahead and run through the wizard, selecting a table via sql query. Note that at the end of this a Nwind.ldb lock has been created in that dir. 4) Generate the Dataset and set the datagrid's datasource property to...
0
1224
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 www.InnoSetup.com). That being said does anyone know how to get "Everyone" to be the default install-base? Thanks in Advance, Christian Blackburn
0
1271
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 on how I can achieve this? -- : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - : my email address zfarjf@pbqrvafvtug.com is encrypted with www.rot13.org
4
15105
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 the default deslection to be the latter. How can I change this, please? Thanks! Ron
1
12583
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 Setup program. >From the Documentation http://msdn2.microsoft.com/en-us/library/5f981xa1.aspx =========================================================== "The InstallAllUsers property for a deployment project determines whether an application is...
0
8974
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9508
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9350
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9218
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8229
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6772
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
3
2199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.