I run my web app in IIS (Windows Server 2012 R2) - which uses XML and an .rpt file to generate a PDF. When trying to use ExportToStream() in debug mode, I get this exception:
Access denied. The file may be in use by another program.
I thought this had something to do with permissions on folders, but I wasn't able to fix it. How can I stop my permissions from being denied?
It should the User you logged in into that computer, then set folder access to full control.
Access denied. The file may be in use by another program.
This Error says the file is already open, Check it in task manager and kill it.
Close all PDF file too..it should be open with same name as you generate a new pdf,It must be unique name.
The permissions were denied because I was using a temporary file, located in C:\TEMP. Adding the group "Everyone" with Full Access solved the problem.
Related
I have a two webservers, on each webserver in the C:\inetpub\logs\LogFiles I have created a symbolic link to the other servers log file folders, so essentially I can be logged in to one of the webservers and see the logs on both servers in one place. This works perfectly.
I am building a webpage to make the log files available via a webpage, the code simply goes to the C:\inetpub\logs\LogFiles directory and lists the files in each sub folder, i.e. W3SVC1 (the local folder) and webserver2-w3svc1 (the remote log folder).
For the local folders it works fine, but I am getting the "access denied" error when trying to call Directory.GetFiles on the symlinkd folder. I suspect this is some sort of permissions error, but I tried giving the symlinkd folder full permissions to "everyone" but I still get the same error.
Is this something to do with the fact that when I created the symlinkd I had to enter the username and password of the webserver2, and these credentials cannot be accessed/used by IIS when trying to get access to the folder?
Is there anything I can do allow IIS to access the contents of this symlinkd folder?
I don't think you need to use a symlink, you can create a virtual directory mapping to that directory in IIS, just map it to the target path. In IIS, right click on the website and select Add Virtual Directory.
For more information, please refer to this official document.
After much experimentation, the only way to do this is as follows:
Create a new user on the computer.
Run the AppPool in IIS under this new users' identity as opposed to the default IUSR account.
Give the folder you are sharing permissions to this user AND 'share' this folder with the new user.
So i've been trying desperately to allow my SharePoint project to write an xml file to a temporary location in my project directory, but haven't had any success.
when I try:
myDataTable.WriteXml("path to folder in project", true);
i'm met with:
"Access to path is Denied"
Now I have had this issue before and have solved it by giving the user group for the application pool write permissions, but it hasn't worked for my sharepoint project. Any suggestions?
You will probably need to elevate privileges in code before calling this method. Look at spsecurity.runwithelevatedprivileges method to run code as the Sharepoint web apps application pool account. You will then need to give that account the correct permission on the file system.
I have to edit a website on local server. I use Windows Server 2012 and IIS. When I try to save a modified file I only get "access denied" error. Do I need to shut down the server before making changes and then restarting it or am I missing permissions for example in the wwwroot folder for IIS_IUSRS?
I have never used WS2012 or IIS before.
You cannot edit files directly in the wwwroot. You need to copy the file/folder out of inetpub to make your edits then paste it back into the wwwroot. This is by design I am afraid.
I was able to do edits directly in the wwwroot files by creating a local user account for myself on the server and giving it FULL access (I am also in the Administrators group - but that was not enough to make it work), then setting the user full access on the SHARE I use to get to the server (via UNC path). Allows edits directly to my live site.
I am running a website over Windows 2003 Server and IIS6 and I am having problems to write or delete files in some temporary folder obtaining this kind of warmings:
Warning: unlink(C:\Inetpub\wwwroot\cakephp\app\tmp\cache\persistent\myapp_cake_core_cake_): Permission denied in C:\Inetpub\wwwroot\cakephp\lib\Cake\Cache\Engine\FileEngine.php on line 254
I went to the tmp directory and at the properties I gave the IIS User the following permissions:
Read & Execute
List folder Contents
Read
And it still showing the same warnings.
When I am on the properties window, if I click on Advanced the IIS username appears twice.
One with Allow type and read & execute permissions and the other with Deny type and Special permissions.
My question is:
Should I give this user not only the Read & Execute permissions but also this ones?:
Create Attributes
Create Files/ Write Data
Create Folders/ Append Data
Delete Subfolders and Files
Delete
They are available to select if I Click on the edit button over the username.
Wouldn't I be opening a security hole if I do this?
Otherwise, how can I do to read and delete the files my website uses?
Thanks.
Finally what I did was giving read/write/modify permissions on app\tmp folder for the Internet Guest Account.
My application is not supposed to perform any administrative tasks, so I want a normal User account to be able to run it. Only thing is, my application reads from and writes to a database file; if the user running Windows 7 (Or Vista) installs my app in drive C, the drive's default permission set configuration doesn't allow my app to write data.
How can I allow my app to write to C:, without requiring full administrative privileges?
If the database file exists at install time you can just grant the user write access to the file as part of the installation process (ordinary users do not have this permission by default). If the file needs to be created by the program the user running the program will need modify permissions on the c drive, which is not something that I would recommend.
I'd suggest storing your db file in Documents and Settings / App data / your app / directory. It exists specifically for this purpose. Writing to C:/Program Files is not so good practice. If that's possible in your case, that is.
You need to open UAC (User Account Access) and set security slider to the bottom. Then you can access drive C: as you did in windows XP.
I decided to modify directory permissions in the setup process, so I created an .exe file that changes the permissions of its start-up path, and gives all users access to that path. I simply included that .exe file in my deployment project, and created a Custom Action that would run the file in the Commit phase of installation.
Because the setup asks the user for administrative rights when it is being installed, my .exe also enjoys administrative privileges and can modify the permissions of the installation directory.
In my .exe, I used a Process instance to run the ACL utility shipped with Windows (icacls.exe) as follows:
ICACLS.EXE [TargetDir] /T /C /grant Users:F
(Make sure that [TargetDir] doesn't end with a "\" or the call will fail.)
This gives all users full control access to the target directory.
I could also write .NET code and change directory permissions manually, but I'm a little lazy!
You may however want to inspect your environment conditions thoroughly so that what you do wouldn't become a security hole in your environment; but this was suitable for me.
I hope this helps others who faced the same issue.
The user by default should have write permissions to drive C:, if not, then you will need to change the directory you read from and write to, to the executing directory (C:/Program Files/Your App/) rather than the root of C:
You can get this by
String Path = Path.GetDirectoryName(Application.ExecutablePath);