473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Setting Read Only Permissions

I am trying to set permissions on a folder programmatically, and have
success fully used the code below for knowledge base article 266461 : How
To: Programmatically Set NTFS File System Folder Permissions Using Microsoft
Visual Basic . NET

However I need to set the permissions to Read Only rather than Full Control,
can any one help me with this.

Dim objADsSec As ADsSecurity

Dim objSecDes As SecurityDescriptor

Dim objDAcl As AccessControlList

Dim objAce As Object

Dim objAce1 As AccessControlEntry

Dim objAce2 As AccessControlEntry

Dim objSId As ADsSID

Dim objSIdHex As Object

objADsSec = New ADsSecurity

objSecDes = CType(objADsSec.GetSecurityDescriptor("FILE://" & vPath),
SecurityDescriptor)

objDAcl = CType(objSecDes.DiscretionaryAcl, AccessControlList)

objSId = New ADsSID

objSId.SetAs(ADSSECURITYLib.ADS_SID_FORMAT.ADS_SID _SAM, CStr(UserName))

objSIdHex = objSId.GetAs(ADSSECURITYLib.ADS_SID_FORMAT.ADS_SID _SDDL)

' Add a new objAce so that the User has Full Control on NTFS Files.

objAce1 = New AccessControlEntry

objAce1.Trustee = CStr(objSIdHex)

objAce1.AccessMask = ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_GENERIC_ALL

objAce1.AceType = ActiveDs.ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOW ED

objAce1.AceFlags = ActiveDs.ADS_ACEFLAG_ENUM.ADS_ACEFLAG_INHERIT_ACE Or
ActiveDs.ADS_ACEFLAG_ENUM.ADS_ACEFLAG_INHERIT_ONLY _ACE Or 1

objDAcl.AddAce(objAce1)

' Add a new objAce so that the User has Full Control on NTFS Folders.

objAce2 = New AccessControlEntry

objAce2.Trustee = CStr(objSIdHex)

objAce2.AccessMask = ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_GENERIC_ALL

objAce2.AceType = ActiveDs.ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOW ED

objAce2.AceFlags = ActiveDs.ADS_ACEFLAG_ENUM.ADS_ACEFLAG_INHERIT_ACE Or 1

objDAcl.AddAce(objAce2)

objSecDes.DiscretionaryAcl = objDAcl

' Set Permissions on the NTFS folder.

objADsSec.SetSecurityDescriptor(objSecDes)

Thanks

Phil

Nov 21 '05 #1
0 1286

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
1
by: byrocat | last post by:
I've got a tool that accesses syslogins to pick up some information. When I run the tool, I get the error message that sasys that my login does not have sufficient permissions to read syslogins....
0
by: Praveen | last post by:
Hello. I am writing some code that accepts a DFS Link and Username and grants that User permissions to the physical directory that the DFS Link corresponds to. I am using the System.Management...
5
by: Mark | last post by:
Hi All, This maybe a really simple question but I need some help. I have been having problems with security and thanks to the help received from a reply to an earlier post, I have found a...
1
by: Bob Sanderson | last post by:
I want to put an Access database back end on a network server so that it can be shared by several users. I plan to use the built-in Access security to set permissions for the database but am...
1
by: Kevin Burton | last post by:
I am using aspnet_setreg but the permissions that it sets the registry to leave the application unable to access the information. I want to add the ASPNET account on the machine that our...
2
by: Phil Hey | last post by:
I am trying to set permissions on a folder programmatically, and have success fully used the code below for knowledge base article 266461 : How To: Programmatically Set NTFS File System Folder...
10
by: John Salerno | last post by:
I always read about how you need to set certain file permissions (for cgi files, for example), but it's never been clear to me *how* you do this. I know you can run the line chmod 755...
0
by: Jesse | last post by:
I've got two directories on the same server, like this: \Public \Private I want to move the directory \Private\myDir into \Public. After I move it, I
5
by: daokfella | last post by:
I have a custom web.config section similar to the following: <CustomAuthSettings attr1="" attr2=""> <Locations RedirectUrl="Invalid.aspx"> <add Path="test.aspx" Roles="1,2,3" Permissions="4,5,6"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.