Access Control List in .net
VB.NET:
Imports System.Security.AccessControl
Imports System.Security.Policy
Imports System.Security.Principal
Imports System.IO
Module Module1
Sub Main()
Dim ds As New DirectorySecurity
ds.AddAccessRule(New FileSystemAccessRule("Guest", FileSystemRights.Read, AccessControlType.Allow))
Directory.CreateDirectory("c:\Guest", ds)
File.Create("c:\Guest\Data.Data")
End Sub
End Module
Imports System.Security.Policy
Imports System.Security.Principal
Imports System.IO
Module Module1
Sub Main()
Dim ds As New DirectorySecurity
ds.AddAccessRule(New FileSystemAccessRule("Guest", FileSystemRights.Read, AccessControlType.Allow))
Directory.CreateDirectory("c:\Guest", ds)
File.Create("c:\Guest\Data.Data")
End Sub
End Module
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Principal;
using System.IO;
namespace AccessControlListCS
{
class Program
{
static void Main(string[] args)
{
DirectorySecurity ds = new DirectorySecurity();
ds.AddAccessRule(new FileSystemAccessRule("Guest", FileSystemRights.Read, AccessControlType.Allow));
Directory.CreateDirectory(@"c:\Guest", ds);
File.Create(@"c:\Guest\Data.Data");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.AccessControl;
using System.Security.Policy;
using System.Security.Principal;
using System.IO;
namespace AccessControlListCS
{
class Program
{
static void Main(string[] args)
{
DirectorySecurity ds = new DirectorySecurity();
ds.AddAccessRule(new FileSystemAccessRule("Guest", FileSystemRights.Read, AccessControlType.Allow));
Directory.CreateDirectory(@"c:\Guest", ds);
File.Create(@"c:\Guest\Data.Data");
}
}
}