ユーザ用ツール

サイト用ツール


acl

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
acl [2014/02/20 23:33] – 作成 nabezoacl [2019/06/30 12:22] (現在) – 外部編集 127.0.0.1
行 19: 行 19:
 c:\scripts\test.txt のアクセス許可を変更します c:\scripts\test.txt のアクセス許可を変更します
    
- Option Explicit +  Option Explicit 
- Dim instance +  Dim instance 
- Dim strMoniker +  Dim strMoniker 
- Dim objDescriptor +  Dim objDescriptor 
- Dim retval +  Dim retval 
- Dim DACL +  Dim DACL 
- Dim controlFlags +  Dim controlFlags 
- Dim accessmask +  Dim accessmask 
- Dim Group +  Dim Group 
- Dim Owner +  Dim Owner 
- Dim SACL +  Dim SACL 
- Dim number_of_trustees +  Dim number_of_trustees 
- Dim trustee_Domain +  Dim trustee_Domain 
- Dim trustee_Name +  Dim trustee_Name 
- Dim trustee_Sidstring +  Dim trustee_Sidstring 
- Dim i +  Dim i 
- Dim strACL  +  Dim strACL  
-  +   
- '' アクセス権のマスク +  '' アクセス権のマスク 
- Const FULLACCESS = 2032127 '' フルアクセス(All) +  Const FULLACCESS = 2032127 '' フルアクセス(All) 
- Const READ = 1179817 '' 読み取り(RX) +  Const READ = 1179817 '' 読み取り(RX) 
- Const UPDATE = 1245631 '' 変更(RWXD) +  Const UPDATE = 1245631 '' 変更(RWXD) 
- Const R = 1179785 '' 特殊なアクセス権(R) +  Const R = 1179785 '' 特殊なアクセス権(R) 
- Const W = 1179926 '' 特殊なアクセス権(W) +  Const W = 1179926 '' 特殊なアクセス権(W) 
- Const X = 1179808 '' 特殊なアクセス権(X) +  Const X = 1179808 '' 特殊なアクセス権(X) 
- Const D = 65536 '' 特殊なアクセス権(D) +  Const D = 65536 '' 特殊なアクセス権(D) 
- Const P = 262144 '' 特殊なアクセス権(P) +  Const P = 262144 '' 特殊なアクセス権(P) 
- Const O = 524288 '' 特殊なアクセス権(O) +  Const O = 524288 '' 特殊なアクセス権(O) 
-  +   
- Const ImpLevel = "{impersonationLevel=impersonate}" +  Const ImpLevel = "{impersonationLevel=impersonate}" 
- Const namespace = "!root\cimv2:" +  Const namespace = "!root\cimv2:" 
- Const objectpath = _+  Const objectpath = _
        "Win32_LogicalFileSecuritySetting=""c:\\scripts\\test.txt"""        "Win32_LogicalFileSecuritySetting=""c:\\scripts\\test.txt"""
        strMoniker = "winmgmts:" & ImpLevel & namespace & objectpath        strMoniker = "winmgmts:" & ImpLevel & namespace & objectpath
- +   
- Set instance = GetObject(strMoniker) +  Set instance = GetObject(strMoniker) 
- If instance Is Nothing Then+  If instance Is Nothing Then
    MsgBox ("インスタンスを取得出来ません。")    MsgBox ("インスタンスを取得出来ません。")
    WSCript.Quit    WSCript.Quit
- End If +  End If 
-  +   
- retval = instance.getsecuritydescriptor(objDescriptor) +  retval = instance.getsecuritydescriptor(objDescriptor) 
-  +   
- Set DACL = objDescriptor.Properties_.Item("dacl") ' get dacl +  Set DACL = objDescriptor.Properties_.Item("dacl") ' get dacl 
- controlFlags = objDescriptor.Properties_.Item("controlflags"+  controlFlags = objDescriptor.Properties_.Item("controlflags"
- Set Group = objDescriptor.Properties_.Item("Group"+  Set Group = objDescriptor.Properties_.Item("Group"
- Set Owner = objDescriptor.Properties_.Item("Owner"+  Set Owner = objDescriptor.Properties_.Item("Owner"
- Set SACL = objDescriptor.Properties_.Item("Sacl"+  Set SACL = objDescriptor.Properties_.Item("Sacl"
-  +   
- number_of_trustees = UBound(DACL.Value) +  number_of_trustees = UBound(DACL.Value) 
- WScript.Echo "ドメイン名\ユーザ名:SID\アクセス権\アクセスマスク" +  WScript.Echo "ドメイン名\ユーザ名:SID\アクセス権\アクセスマスク" 
- For i = 0 To number_of_trustees+  For i = 0 To number_of_trustees
    Set trustee_Domain = DACL.Value(i).Properties_.Item _    Set trustee_Domain = DACL.Value(i).Properties_.Item _
        ("trustee").Value.Properties_.Item("Domain")        ("trustee").Value.Properties_.Item("Domain")
行 77: 行 77:
    Set trustee_Sidstring = DACL.Value(i).Properties_.Item _    Set trustee_Sidstring = DACL.Value(i).Properties_.Item _
        ("trustee").Value.Properties_.Item("Sidstring")        ("trustee").Value.Properties_.Item("Sidstring")
- +  
    accessmask = DACL.Value(i).Properties_.Item _    accessmask = DACL.Value(i).Properties_.Item _
        ("AccessMask").Value ' Save the accessmask        ("AccessMask").Value ' Save the accessmask
- +  
    Select Case accessmask    Select Case accessmask
        Case FULLACCESS        Case FULLACCESS
行 91: 行 91:
            strACL = accessmask            strACL = accessmask
    End Select    End Select
- +  
    WScript.Echo trustee_domain & "\" & trustee_name & ":" & trustee_Sidstring & ":" & strACL & ":" & accessmask    WScript.Echo trustee_domain & "\" & trustee_name & ":" & trustee_Sidstring & ":" & strACL & ":" & accessmask
- +  
    If trustee_name = "Administrators" Then    If trustee_name = "Administrators" Then
        'アクセス許可の設定        'アクセス許可の設定
行 100: 行 100:
            ("AccessMask").Value = R            ("AccessMask").Value = R
    End If    End If
- Next +  Next 
-  +   
- retval = instance.setsecuritydescriptor(objDescriptor) +  retval = instance.setsecuritydescriptor(objDescriptor) 
- If retval = 0 Then+  If retval = 0 Then
    MsgBox "成功しました。"    MsgBox "成功しました。"
- Else+  Else
    MsgBox "セキュリティ設定を変更できませんでした。"    MsgBox "セキュリティ設定を変更できませんでした。"
- End If +  End If 
- Set instance = Nothing +  Set instance = Nothing 
- WSCript.Quit+  WSCript.Quit 
 +  
acl.1392906793.txt.gz · 最終更新: 2019/06/30 12:22 (外部編集)