1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| Function Set-IISACL
{
Param ($Username, $LogDir)
$Account = New-Object System.Security.Principal.Ntaccount("$Username")
$Sid = $Account.Translate([System.Security.Principal.SecurityIdentifier])
$ACL = Get-Acl -Path "$LogDir"
$ACL.SetAccessRuleProtection($True, $True)
Set-Acl -Path "$LogDir" -AclObject $ACL
$Permission = "$Account","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow"
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
$ACL.SetAccessRule($AccessRule)
$ACL | Set-Acl "$LogDir"
$Account = New-Object System.Security.Principal.Ntaccount("$Username")
$Sid = $Account.Translate([System.Security.Principal.SecurityIdentifier])
$ACL = Get-Acl -Path "$LogDir\db"
$Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow"
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
$ACL.SetAccessRule($AccessRule)
$ACL | Set-Acl "$LogDir\db"
$Account = New-Object System.Security.Principal.Ntaccount("$Username")
$Sid = $Account.Translate([System.Security.Principal.SecurityIdentifier])
$ACL = Get-Acl -Path "$LogDir\http\upload"
$Permission = "$Account","modify","ContainerInherit,ObjectInherit","None","Allow"
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
$ACL.SetAccessRule($AccessRule)
$ACL | Set-Acl "$LogDir\http\upload"
} |