Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Assigning NTFS rights to files

Posted on 2005-04-14
7
Medium Priority
?
217 Views
Last Modified: 2012-03-15
Hi Experts, I am developing an application that requires to configure the rights (for instance only read access) to specified files that are stored in the database based on the login ID. In the database, it has been setup for each login ID, the specified files with its assoicated rights. Now my problem is to be able to set this rights to the files accordingly as specified in the database.

TIA.
0
Comment
Question by:bpyeo
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:wraith821
ID: 13789893
xcacls.exe (a microsoft command line utility)

http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/xcacls-o.asp

you can use shell to call it. or wscript.
0
 
LVL 5

Expert Comment

by:RainUK
ID: 13790215
You need to use these APIs

GetKernelObjectSecurity
AddSecurityDescriptor
SetKernelObjectSecurity
0
 

Author Comment

by:bpyeo
ID: 13796873
Hi RainUK, do you have any code sample for your recommendation.

TIA.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Expert Comment

by:RainUK
ID: 13804287
0
 

Author Comment

by:bpyeo
ID: 13813871
Hi RainUK, I have visited the a/m URL and it is mainly to change the owner of a file/folder and not setting the rights to file/folder. Please advice on the setting of rights (for instance, only read access) to file/folder.

TIA.
0
 
LVL 5

Accepted Solution

by:
RainUK earned 1500 total points
ID: 13813896
Okay go to this link

http://support.microsoft.com/default.aspx?scid=kb;en-us;316440

Download the SetPerm.exe

In the module SetPerm.Bas look at the public function named UpdatePermissionsOfFolder.
But note that the folder/file must already exist before you set the permissions on it!!!

0
 
LVL 8

Expert Comment

by:wraith821
ID: 13814381
Guaranteed this is the easiest way to set file attributes Using FileSystemobject. you need to play with it though, test good because you can get the attributes messed up, for instance if  a file is readonlly and you set system on it, it could remove readonly so you have to set it to 5(4+1) for read only and system.

Attributes Property
See Also    Example    Applies To    Specifics

Description

Sets or returns the attributes of files or folders. Read/write or read-only, depending on the attribute.

Syntax

object.Attributes [= newattributes]

The Attributes property has these parts:

Part Description
object Required. Always the name of a File or Folder object.
newattributes Optional. If provided, newattributes is the new value for the attributes of the specified object.


Settings

The newattributes argument can have any of the following values or any logical combination of the following values:

Constant     Value          Description
Normal         0              Normal file. No attributes are set.
ReadOnly      1             Read-only file. Attribute is read/write.
Hidden          2             Hidden file. Attribute is read/write.
System         4             System file. Attribute is read/write.
Volume         8             Disk drive volume label. Attribute is read-only.
Directory       16           Folder or directory. Attribute is read-only.
Archive         32           File has changed since last backup. Attribute is read/write.
Alias             64           Link or shortcut. Attribute is read-only.
Compressed  128         Compressed file. Attribute is read-only.

The following code illustrates the use of the Attributes property with a file:

Sub SetClearArchiveBit(filespec)
    Dim fs, f, r
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(fs.GetFileName(filespec))
    If f.attributes and 32 Then
        r = MsgBox("The Archive bit is set, do you want to clear it?", vbYesNo, "Set/Clear Archive Bit")
        If r = vbYes Then
            f.attributes = f.attributes - 32
            MsgBox "Archive bit is cleared."
        Else
            MsgBox "Archive bit remains set."
        End If
    Else
        r = MsgBox("The Archive bit is not set. Do you want to set it?", vbYesNo, "Set/Clear Archive Bit")
        If r = vbYes Then
            f.attributes = f.attributes + 32
            MsgBox "Archive bit is set."
        Else
            MsgBox "Archive bit remains clear."
        End If
    End If
End Sub

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question