8

サーバーをゼロからセットアップして、Web アプリケーションの一部としてサービスの 1 つを実行する Powershell スクリプトを作成するタスクを与えられました。このサーバーをセットアップするために必要な手順の 1 つは、インストールされたサービスの DCOM 構成を変更することです。 、具体的にはアカウントを「起動とアクティベーション」/「アクセス」権限に追加し、追加後にこれらのアカウントの権限を設定します。

Powershellを使用してこれを行う方法はありますか? 私が達成しようとしていることを行うための具体的な方法を見つけることができなかったので、どんな助けも素晴らしいでしょう

4

2 に答える 2

16

WMIを使用して行うようです。

Win32_DCOMApplicationSetting次のように: のインスタンスを取得します。

$dcom = Get-WMIObject -Class Win32_DCOMApplicationSetting -Filter 'Description="Something"'

SetAccessSecurityDescriptorこれで、 メソッドとメソッドにアクセスできるようになりましたSetLaunchSecurityDescriptor

から: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384905(v=vs.85).aspx

DCOM アプリケーション

DCOM アプリケーション インスタンスには、いくつかのセキュリティ記述子があります。Windows Vista 以降では、Win32_DCOMApplicationSetting クラスのメソッドを使用して、さまざまなセキュリティ記述子を取得または変更します。セキュリティ記述子は、Win32_SecurityDescriptor クラスのインスタンスとして返されます。

構成アクセス許可を取得または変更するには、GetConfigurationSecurityDescriptor または SetConfigurationSecurityDescriptor メソッドを呼び出します。

アクセス許可を取得または変更するには、GetAccessSecurityDescriptor または SetAccessSecurityDescriptor メソッドを呼び出します。

起動とアクティブ化のアクセス許可を取得または変更するには、GetLaunchSecurityDescriptor または SetLaunchSecurityDescriptor メソッドを呼び出します。

Windows Server 2003、Windows XP、Windows 2000、Windows NT 4.0、および Windows Me/98/95: Win32_DCOMApplicationSetting セキュリティ記述子メソッドは使用できません。

DCOMPERM というツールもあり、ソース コードは Windows SDK で入手できます: http://www.microsoft.com/en-us/download/details.aspx?id=8279

DCOMPERM コンパイル済みを検索すると、オンラインでコンパイル済みバージョンを見つけることができます。

コマンド ライン オプションは次のとおりです。

Syntax: dcomperm <option> [...] 
Options:

Modify or list the machine access permission list 
-ma <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r"] 
-ma list

Modify or list the machine launch permission list 
-ml <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r,ll,la,rl,ra"] 
-ml list

Modify or list the default access permission list 
-da <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r"] 
-da list

Modify or list the default launch permission list 
-dl <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r,ll,la,rl,ra"] 
-dl list

Modify or list the access permission list for a specific AppID 
-aa <AppID> <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r"] 
-aa <AppID> default 
-aa <AppID> list

Modify or list the launch permission list for a specific AppID 
-al <AppID> <"set" or "remove"> <Principal Name> ["permit" or "deny"] ["level:l,r,ll,la,rl,ra"] 
-al <AppID> default 
-al <AppID> list

level: 
    ll - local launch (only applies to {ml, dl, al} options) 
    rl - remote launch (only applies to {ml, dl, al} options) 
    la - local activate (only applies to {ml, dl, al} options) 
    ra - remote activate (only applies to {ml, dl, al} options) 
    l - local (local access - means launch and activate when used with {ml, dl, al} options) 
    r - remote (remote access - means launch and activate when used with {ml, dl, al} options)
于 2012-07-10T01:38:04.707 に答える
8

OPと同じ質問がありました。Andy が投稿した回答は非常に役に立ち、道半ばでした。次に、SharePoint の展開を支援するために誰かが作成したSet-DCOMLaunchPermissionsを見つけました。

それらの機能を自分の目的に合わせて調整し、必要なアクセス許可を設定するソリューションを考え出しました。

$user = "sql2012agent"
$domain = "MYDOMAIN"
$appdesc = "Microsoft SQL Server Integration Services 11.0"
$app = get-wmiobject -query ('SELECT * FROM Win32_DCOMApplicationSetting WHERE Description = "' + $appdesc + '"') -enableallprivileges
#$appid = "{83B33982-693D-4824-B42E-7196AE61BB05}"
#$app = get-wmiobject -query ('SELECT * FROM Win32_DCOMApplicationSetting WHERE AppId = "' + $appid + '"') -enableallprivileges
$sdRes = $app.GetLaunchSecurityDescriptor()
$sd = $sdRes.Descriptor
$trustee = ([wmiclass] 'Win32_Trustee').CreateInstance()
$trustee.Domain = $domain
$trustee.Name = $user
$fullControl = 31
$localLaunchActivate = 11
$ace = ([wmiclass] 'Win32_ACE').CreateInstance()
$ace.AccessMask = $localLaunchActivate
$ace.AceFlags = 0
$ace.AceType = 0
$ace.Trustee = $trustee
[System.Management.ManagementBaseObject[]] $newDACL = $sd.DACL + @($ace)
$sd.DACL = $newDACL
$app.SetLaunchSecurityDescriptor($sd)
于 2014-02-28T20:03:35.320 に答える