中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

WMIとかADSIとかは情報が少ないですねぇ。

WMIとかADSIとかは情報が少ないですねぇ。

そしていまやFileSystemObjectすらも。

適当に書いておくので切り刻んでください。

'指定されたユーザ名で指定されたパスのフルコントロールアクセス権をつける。
Function SetSecurityHomeDirectory(strComputer , strUser, HomePath)
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  SetSecurityHomeDirectory = False
  'アカウント取得
  Set wmiAccounts =  objWMIService.ExecQuery ( "select * from Win32_Account where Name='" & strUser & "'")
  For Each obj in wmiAccounts
    Set wmiAccount = obj
    Exit For 
  Next

  'Trusteeに変換する
  Set wmiTrusteeClass = objWMIService.Get("Win32_Trustee")
  Set wmiTrustee = wmiTrusteeClass.spawnInstance_()
  Set wmiSID = objWMIService.Get("Win32_SID.SID='" & wmiAccount.sid & "'")
  wmiTrustee.domain = wmiSID.ReferencedDomainName
  wmiTrustee.name = wmiSID.AccountName
  wmiTrustee.sid = wmiSID.BinaryRepresentation
  wmiTrustee.sidLength = wmiSID.sidLength
  wmiTrustee.sidString = wmiSID.sid
  'ACEオブジェクトを作成する
  Set wmiACEClass = objWMIService.get("Win32_ACE")
  Set wmiACE = wmiACEClass.spawnInstance_()
  wmiACE.AccessMask = 1+2+4+8+16+32+64+128+256+65536+131072+262144+524288+1048576 ' 2032127
  wmiACE.trustee = wmiTrustee
  wmiACE.AceType = 0
  wmiACE.AceFlags = 3

  '対象フォルダのセキュリティデスクリプタを取得する
  Set wmiFileSecSetting = GetObject( "winmgmts:Win32_LogicalFileSecuritySetting.path='" & HomePath & "'")
  RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)
  If ( RetVal <> 0 ) Then
    WScript.Echo "GetSecurityDescriptorに失敗しました:" & RetVal
    Exit Function
  End If

  'ディクショナリにDACLを転記する
  Set DictACE = CreateObject("Scripting.Dictionary")
  For i = LBound(wmiSecurityDescriptor.DACL) to UBound(wmiSecurityDescriptor.DACL)
    If (  not wmiSecurityDescriptor.DACL(i).AceFlags and 16 ) Then
      Call DictACE.Add( i, wmiSecurityDescriptor.DACL(i) )
    End if
  Next

  '設定する新しいACEオブジェクトを最後に足す
  Call DictACE.add( "NewUser", wmiACE )

  'DACLに書き戻す
  wmiSecurityDescriptor.DACL = DictACE.Items

  '対象フォルダのセキュリティデスクリプタを設定する
  RetVal = wmiFileSecSetting.SetSecurityDescriptor(wmiSecurityDescriptor)
  If ( RetVal <> 0 ) Then
    WScript.Echo "SetSecurityDescriptorに失敗しました:" & RetVal
    Exit Function
  End If
  SetSecurityHomeDirectory = True
End Function

投稿日時 : 2006年9月17日 1:51

コメントを追加

# can you buy prednisone over the counter in canada https://prednisonesnw.com/#
prednisone in india 2021/11/13 9:38 Prednisone

can you buy prednisone over the counter in canada https://prednisonesnw.com/#
prednisone in india

# clomid purchase https://clomidt.com
clomid online cheap 2022/01/03 19:19 Clomid

clomid purchase https://clomidt.com
clomid online cheap

# pills for erection https://cheapestedpills.com/
new ed treatments 2022/12/10 22:16 CheapPills

pills for erection https://cheapestedpills.com/
new ed treatments

# buy cytotec online - https://cytotecsale.pro/# 2023/04/29 6:30 Cytotec

buy cytotec online - https://cytotecsale.pro/#

# cvs over the counter covid test https://overthecounter.pro/# 2023/05/09 0:36 OtcJikoliuj

cvs over the counter covid test https://overthecounter.pro/#

# medication for ed https://edpill.pro/# - ed medication online 2023/06/27 16:03 EdPills

medication for ed https://edpill.pro/# - ed medication online

# cytotec pills buy online https://cytotec.ink/# - buy cytotec pills 2023/07/26 20:32 PillsFree

cytotec pills buy online https://cytotec.ink/# - buy cytotec pills

# pills for erection https://edpills.ink/# - cure ed 2023/07/27 2:27 EdPills

pills for erection https://edpills.ink/# - cure ed

# paxlovid buy https://paxlovid.bid/ paxlovid covid 2023/10/26 0:37 Paxlovid

paxlovid buy https://paxlovid.bid/ paxlovid covid

# order doxycycline 100mg without prescription https://doxycycline.forum/ doxycycline 100mg capsules 2023/11/25 14:40 Doxycycline

order doxycycline 100mg without prescription https://doxycycline.forum/ doxycycline 100mg capsules

# farmacie online affidabili https://farmaciait.pro/ farmacie on line spedizione gratuita 2023/12/04 11:17 Farmacia

farmacie online affidabili https://farmaciait.pro/ farmacie on line spedizione gratuita

# abella danger filmleri https://abelladanger.online/ abella danger filmleri
2024/03/04 21:23 Adella

abella danger filmleri https://abelladanger.online/ abella danger filmleri

# eva elfie full videos https://evaelfie.site/ eva elfie new video
2024/03/07 6:53 EvaElfie

eva elfie full videos https://evaelfie.site/ eva elfie new video

# aviator bet: https://aviatorghana.pro/ play aviator
2024/03/12 11:28 AviatorGh

aviator bet: https://aviatorghana.pro/ play aviator

# order cytotec online https://cytotec.club/ cytotec pills online 2024/04/28 0:16 Cytotec

order cytotec online https://cytotec.club/ cytotec pills online

タイトル
名前
URL
コメント