.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Modify File Permissions

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :Sql Server
SQL Server 2005/2008 Ent. When trying to move the database files from one drive to another I get a permission denied error. The process is: ALTER DATABASE db_name SET OFFLINE WITH ROLLBACK AFTER 30 SECONDS (this works) Move files to new drive (this works) ALTER DATABASE db_name MODIFY  FILE ( NAME= logical_name, FILENAME = 'new_path\filename') (This doesn't work*) ALTER DATABASE db_name SET ONLINE (this works) * This exact method is part of an internal application. When the applicaiton is run as a user ('admin') that has: sysadmin role it works as expected. When run as a user ('restricted') that has just: db_creator (instance wide) db_owner (just the one database) db_diskadmin (instance wide) it fails with a user doesn't have alter permissions for the databse ... I have tried:  all of the steps manually as the 'restriced' user to make sure it isn't something wrong with our app. all of the setps manually as the 'admin' user setting the database owner to another acount and explicitly given all permissions to the 'restricted' account From what I have read the databse owner (dbo) user should be able to do any ALTER statement to the databse. And it is able to take the database offline but it can't change the file paths. Is there no other way to do this without giving sysadmin to the application service account?

View Complete Post

More Related Resource Links

Access Control: Understanding Windows File And Registry Permissions


Understanding the ACLs that govern permissions and rights before an operation is allowed to proceed is critical to enhancing security.

John R. Michener

MSDN Magazine November 2008

WPF Desktop App - Write file permissions

I have been working on a WPF desktop app for a while now, and I am struggling to deploy it.  The problem seems to be that the app does not have permissions to save the file I am creating.  Although I should say the code works fine running locally through Visual Studio. I am OneClick deploying the app, and just want to give it full access although just knowing how to give it write permission is all I need.  The app is only to be used by a few members of staff on our intranet, so trust is not really an issue here. If anyone can point me in the direction of a quick solution that would be great, and you'll save me alot of time trying to figure out all the documentation which I am failing to work out what to do with so far. Additional info: I am deploying over a web address, which I think means Internet Zone. Thanks John

File not found error when trying to open site permissions on a blog site

We have created a simple team site and a block subsite.  When trying to edit the site permissions we see the following error.  Any ideas? When opening a blog site and clicking Site Actions - site permissions we received a new page with the following error: Error File Not Found Troubleshoot issue with Microsoft Sharepoint Foundation Correlation ID: 51b54786-f344-4474-b88e-3080c363693 Date and Time: 3/24/2010 3:03:38 PM

Changing File Permissions of Disconnected MDF/LDF Files

I am a university professor and have over a hundred student project databases using the developer edition of SQL 2005 and 2008 on a portable hard drive.  All are disconnected from any server.  I need to move these to a new hard drive but no file system tool I can find will let me copy the .mdf or .ldf files.  Each of these files has a single user with permissions and the user is a long alpha/numeric string that seems to have been generated by SQL.  I can copy these files if I select each file individually and give full control permissions to my current login.  On some files I need to first take ownership.  I just don't want to have to go in and do this manually for 200+ files scattered all over the drive. I really need some sort of batch approach (including something that can be launched from within VB which I can use to navigate my drive's folder structure looking for .mdf/.ldf files) to let me change the permissions on these files.  As I said, I have a LOT of them and they are scattered around a deep folder structure organized by semester, course, project team, and sometimes project version.  Further, the files accompany other files such as VB projects, report projects, SSIS projects, etc.  I have access to Windows Vista and Windows 7 for doing this.

Error when modifying permissions on Itemadded for a file upload

All, I have registered an eventhandler for a document library. On ItemAdded, I want to modify the permissions of the item such that only the uploader(creator) should have access to the file he is uploading. When I upload a file and fill in the required metadata and click on Save, I get the error"The file SubmissionForReview_Draft/Untitled.htm has been modified by SHAREPOINT\system " . But, I did verify the event fired and all appropriate permissions are set. The only explanation for this could be, the file gets uploaded, the event fired and the properties of the file has changed and then the form to add additional metadata has poped up. On clicking on save, SharePoint determines that the file for which the metadata has to be added has changed internally and throws error, which may be as expected. Question: Is there a way around this issue, maybe to suppress check on file changed ?   Thanks mano Mano Mangaldas | Blog : http://howtosharepoint.blogspot.com 

SQL Server 2008 file permissions


We're converting from SQL Server 2000 to 2008. We've set up a new DB server (Windows 2003 Server), we've installed SQL Server 2008. We've installed a few databases. Things seemed to be going well. Then...

I'm trying to move over a database from the old server to the new. I've tried detach/copy/attach and backup/copy/restore. I'm putting the file in the default database location (D:\MSSQL\Data or D:\MSSQL\Backup). But then I find that SQL Server can no longer access that location! I get a message that says:

"Cannot access the specified path or file on the server. Verify that you have the necessary security priveleges and that the path or file exists".

This as soon as I click on Add on the Specify Backup dialog or on the Attach database dialog.

I've tried: logging in with SQL Server authent. and Windows authent.; checking and changing permission on the folder and file; basically everything I can think of.




Search Results from File Shares - Respect Permissions?????


I'm curious: If I have SP 2010 Enterprise and I've set it up to crawl and return search results from documents on a file share, will it respect the access permissions that the logged-in user doing the searching has?

I know I have to allow read-only access for the content manager account within SP, but I did not know if it would check access permissions of the user account when returning results.


Remote File Permissions

I have a large scale computer system where all of the computers are configured in the same way. I need to copy a folder from an administrative computer to all of the computers on the network, but the problem is I need to be able to copy the files impersonating the administrator account for each computer. Does anybody know how to programmatically, using .Net, set the user identity for a remote computer so that a file can be copied to that computer? Thanks.

retrieve NTFS file / folder permissions


Using .NET 4.0, is there a good way to retrieve the NTFS permissions for a given file or folder?   Specifically, I would like to know if the current Windows user has write / delete permissions for a given folder.   I don't want to modify the permissions, just want to look at them to know if its safe to continue running.





File Permissions for Private Key/Certificate Exported from SQL 2008


As part of our new key management system for SQL server, we are backing up the Private Key and Certificate file to a UNC file path that has very restricted access to only Key and Certificate custodians.  When we execute the backup script, it works and puts the Certificate and Key files to the UNC path, but the files do not inherit NTFS permissions from the target path and our Key and Certificate Custodians do not have access to these files.  Is there a way to "force" these files to inherit permissions from their target folder structure?

Here is the SQL script used to generate our key pair:


  TO FILE = '\\UNCCertificatePath\CertificateFile.cert’

Why do you need delete permissions to edit the file name of a document in a document library?How can

I have a document library and a group of users who should be able to upload documents and only change the metadata. They should not be able to edit the document or delete the document. So I setup a permission level with Add and Edit Items. When the user uploads the document, the edit form is shown where he/she changes the file name and comment fields, but the users get "Access Denied " error. I noticed that the error must be because the user is changing the file name field, as the document is uploaded and the comments field is also updated but the file name is not changed. But if I give Delete permissions to these users, the error disappears. I do not want to give them Delete permissions but I want to allow them to change the file name, can anyone help me here about how to achieve this? Also How do I prevent them from editing the document but still they can edit the metadata?

Any help would be greatly appreciated..


Permissions to modify SQL Agent Jobs


Outside of the 3 new roles added to MSDB, does anyone know what or how to allow a user group to have rights to modify SQL Agent Jobs that they do not own without granting dbo or sysadmin rights?

All the permissions I thought would be needed are in SQLAgentOperator/User Roles, but they still can not modify a job they don't own.


John M. Couch

File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

SmtpClient and Locked File Attachments

Got a note a couple of days ago from a client using one of my generic routines that wraps SmtpClient. Apparently whenever a file has been attached to a message and emailed with SmtpClient the file remains locked after the message has been sent. Oddly this particular issue hasn't cropped up before for me although these routines are in use in a number of applications I've built.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend