Re: Setting folder permissions
- From: "David" <david.colliver.NEWS@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 19 Mar 2008 15:12:44 -0000
More info...
If I add my serviceuser into the admins group, everything works. Just having
them in the users group, it fails.
I have made the parent folder Users group have Full Control permissions on
it. These permissions are being copied into the newly created folder, but I
still can't move my files into the folder. On the move, I get an
UnauthorizedAccessException.
:-(
Any clues as to where I should look will be VERY much appreciated.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"David" <david.colliver.NEWS@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:uYLnY2ciIHA.3512@xxxxxxxxxxxxxxxxxxxxxxx
Thank you...
My service was running under LOCAL SERVICE initially, so I have changed
it. I changed it to my admin account and got everything working.
Since then, I have given it a less priviledged account (an account
initially with guest priviledges) and it stops. So, I promoted it to the
Users group and it still fails, however, it looks like a different
failure.
I don't have a domain here, so I am using local accounts to test it...
What happens now is that the folder is created and the account that the
service uses is added to the folder permissions. I am guessing that is
because effectively, my service account is the owner of the service.
However, when I check the permissions, absolutely no permissions have been
granted, just the account is in the list.
My code to assign permissions is...
dirSec.AddAccessRule(new
FileSystemAccessRule(ConfigurationManager.AppSettings["ServiceAccount"],
FileSystemRights.Modify, AccessControlType.Allow));
The above line now does not fail where it did before. So, now I don't know
what else to do...
Thanks.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Peter Ritchie [C# MVP]" <PRSoCo@xxxxxxxxxxxxxxxxx> wrote in message
news:7BA8BF08-D86A-4B28-895D-1690A06EB593@xxxxxxxxxxxxxxxx
You have to make sure that first the login under which the service is
running
(defaults to SYSTEM) has permission to do the operations you're
requesting on
the host in the UNC. I think by default the SYSTEM account on one
computer
has no such rights on another computer. You'll probably want to
install/configure your service to use a specific login that has
permission to
create directories (etc).
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"David" wrote:
Hi,
I am creating a windows service. This service has a filewatcher on it.
When I drop a file, I want to parse the filename then create the
directory.
The directory will be in a filestore server so I am passing in a UNC
path.
The filestore directory will then also be a virtual directory within an
ASP.NET application, so I need to take those permissions into
consideration.
I am having problems setting the permissions. The error is
UnauthorizedAccessException.
Here is my code...
string RootPath =
ConfigurationManager.AppSettings["StorePathRoot"];
string[] Folder = e.Name.Split('_');
if (Folder[0] != string.Empty)
{
RootPath += Folder[0] + "\\";
if (!Directory.Exists(RootPath))
{
Directory.CreateDirectory(RootPath);
DirectoryInfo hInfo = new
DirectoryInfo(RootPath);
DirectorySecurity dirSec =
hInfo.GetAccessControl();
dirSec.AddAccessRule(new
FileSystemAccessRule(@"david\Everyone", FileSystemRights.Modify,
AccessControlType.Allow));
dirSec.AddAccessRule(new
FileSystemAccessRule(@"david\LOCAL SERVICE", FileSystemRights.Modify,
AccessControlType.Allow));
hInfo.SetAccessControl(dirSec);
}
}
System.IO.File.Move(e.FullPath, RootPath + e.Name);
I set the path in the app.config. This is a UNC path (currently to my
pc,
but will go to a network share). As you can see, I am trying to give
"Everyone" permisssion and "LOCAL SERVICE" permission. It is actually
failing on the first one, "Everyone". The directory is being created
fine.
In fact, if I didn't have the permission routine, when I copy a file
into my
drop folder, it does get moved, though if I copy 2 files into the drop
folder, it stops. (I am copying an xml and a pdf file with the same
first
part of the filename, i.e. test_1.xml and test_1.pdf )
Any help appreciated.
Thanks.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
.
- References:
- Setting folder permissions
- From: David
- RE: Setting folder permissions
- From: Peter Ritchie [C# MVP]
- Re: Setting folder permissions
- From: David
- Setting folder permissions
- Prev by Date: Re: Finding a resource leak, is it the background thread or something else?
- Next by Date: Re: Setting folder permissions
- Previous by thread: Re: Setting folder permissions
- Next by thread: Re: Setting folder permissions
- Index(es):
Relevant Pages
|