Click here to Skip to main content
15,887,214 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: multiple file search Pin
P P Vilsad11-May-07 10:11
P P Vilsad11-May-07 10:11 
GeneralRe: multiple file search Pin
jds120711-May-07 10:26
jds120711-May-07 10:26 
GeneralRe: multiple file search Pin
P P Vilsad11-May-07 10:35
P P Vilsad11-May-07 10:35 
QuestionVB GIS Project Pin
Zigoxo11-May-07 5:43
Zigoxo11-May-07 5:43 
AnswerRe: VB GIS Project Pin
Colin Angus Mackay11-May-07 5:53
Colin Angus Mackay11-May-07 5:53 
Questionregarding datagrid problem in vb.net? Pin
sathyan_829411-May-07 5:18
sathyan_829411-May-07 5:18 
AnswerRe: regarding datagrid problem in vb.net? Pin
Kevin Nicol11-May-07 7:35
Kevin Nicol11-May-07 7:35 
QuestionSetting Permissions for new folders .NET 2.0 Pin
aro198111-May-07 4:35
aro198111-May-07 4:35 
Setting permissions for new folders .NET 2.0 8mins ago

Hello,
I have seen the vb.net sample code on msdn for setting permissions for new folders (below), but still have some questions about it. I am writing a program that creates new folders, and sets permissions for the new folders. An Access database contains the permissions for each group. I have found very little information and examples for this subject. If anyone is familiar with security and the .NET 2.0 framework, I would greatly appreciate the help. Thank you for reading this message!

Imports System
Imports System.IO
Imports System.Security.AccessControl



Module DirectoryExample

Sub Main()
Try
Dim DirectoryName As String = "TestDirectory"

Console.WriteLine("Adding access control entry for " + DirectoryName)

' Add the access control entry to the directory.
AddDirectorySecurity(DirectoryName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AccessControlType.Allow)

Console.WriteLine("Removing access control entry from " + DirectoryName)

' Remove the access control entry from the directory.
RemoveDirectorySecurity(DirectoryName, "MYDOMAIN\MyAccount", FileSystemRights.ReadData, AccessControlType.Allow)

Console.WriteLine("Done.")
Catch e As Exception
Console.WriteLine(e)
End Try

Console.ReadLine()

End Sub


' Adds an ACL entry on the specified directory for the specified account.
Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
' Create a new DirectoryInfoobject.
Dim dInfo As New DirectoryInfo(FileName)

' Get a DirectorySecurity object that represents the
' current security settings.
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()

' Add the FileSystemAccessRule to the security settings.
dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))

' Set the new access settings.
dInfo.SetAccessControl(dSecurity)

End Sub


' Removes an ACL entry on the specified directory for the specified account.
Sub RemoveDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
' Create a new DirectoryInfo object.
Dim dInfo As New DirectoryInfo(FileName)

' Get a DirectorySecurity object that represents the
' current security settings.
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()

' Add the FileSystemAccessRule to the security settings.
dSecurity.RemoveAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))

' Set the new access settings.
dInfo.SetAccessControl(dSecurity)

End Sub
End Module



AR






AR
QuestionSAP.net Connector Pin
sunder vel11-May-07 3:38
sunder vel11-May-07 3:38 
AnswerRe: SAP.net Connector Pin
Dave Kreskowiak11-May-07 3:58
mveDave Kreskowiak11-May-07 3:58 
Questioncode for forex exchange using vb.net 2003 Pin
Stormint11-May-07 3:19
Stormint11-May-07 3:19 
AnswerRe: code for forex exchange using vb.net 2003 Pin
Dave Kreskowiak11-May-07 3:57
mveDave Kreskowiak11-May-07 3:57 
AnswerRe: Data Reports Pin
Dave Kreskowiak11-May-07 3:55
mveDave Kreskowiak11-May-07 3:55 
QuestionVisual Basic.Net Integration Pin
Vimalsoft(Pty) Ltd11-May-07 2:24
professionalVimalsoft(Pty) Ltd11-May-07 2:24 
AnswerRe: Visual Basic.Net Integration Pin
Christian Graus11-May-07 2:30
protectorChristian Graus11-May-07 2:30 
GeneralRe: Visual Basic.Net Integration Pin
Vimalsoft(Pty) Ltd11-May-07 2:44
professionalVimalsoft(Pty) Ltd11-May-07 2:44 
GeneralRe: Visual Basic.Net Integration Pin
Steven J Jowett11-May-07 3:12
Steven J Jowett11-May-07 3:12 
GeneralRe: Visual Basic.Net Integration Pin
Dave Kreskowiak11-May-07 3:53
mveDave Kreskowiak11-May-07 3:53 
QuestionHow to disable Ctrl P keys in vb.net Pin
koolprasad200311-May-07 2:22
professionalkoolprasad200311-May-07 2:22 
AnswerRe: How to disable Ctrl P keys in vb.net Pin
Christian Graus11-May-07 2:30
protectorChristian Graus11-May-07 2:30 
GeneralRe: How to disable Ctrl P keys in vb.net Pin
Dave Kreskowiak11-May-07 3:45
mveDave Kreskowiak11-May-07 3:45 
AnswerRe: How to disable Ctrl P keys in vb.net Pin
Dave Kreskowiak11-May-07 3:47
mveDave Kreskowiak11-May-07 3:47 
GeneralRe: How to disable Ctrl P keys in vb.net Pin
Christian Graus11-May-07 18:06
protectorChristian Graus11-May-07 18:06 
Questionsetup in vb.net 2005 Pin
Sonia Gupta11-May-07 2:17
Sonia Gupta11-May-07 2:17 
AnswerRe: setup in vb.net 2005 Pin
Christian Graus11-May-07 2:32
protectorChristian Graus11-May-07 2:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.