2012-07-06 200 views
7

Powershellスクリプトを記述して、Webアプリケーションの一部としてサーバーを設定し、このサーバーの設定に必要な手順の1つを実行するようにサーバーを設定する作業が与えられました「起動とアクティベーション」/「アクセス」権限にアカウントを追加し、これらのアカウントが追加されるとその権限を設定します。Powershellを使用してDCOM設定のセキュリティ設定を変更する

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

答えて

12

あなたはWMIを使っているようです。このようなWin32_DCOMApplicationSetting

はのインスタンスを取得します

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

今、あなたはSetAccessSecurityDescriptorSetLaunchSecurityDescriptorメソッドへのアクセス権を持っています。

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セキュリティ 記述子メソッドは使用できません。

ソースコードは、Windows SDKで提供されているDCOMPERMというツールもあります: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) 
+0

ありがとう、アンディー、それは多くの助けになりました!最後に私は両方の方法の混合を使用しました。 Win32_DCOMApplicationSettingを使用してアプリケーションIDを取得した後、DComPermを使用して必要なアクセス許可を追加しました。私が少し奇妙なことに気がついたのは、CMDがPowershellよりも問題の少ないDcomPermを実行していたため、私は必要なものを達成するために、特定の変数が渡されたバッチファイルを書き、Powershellから呼び出しました。 – Vermin

+0

@Vermin私の推測ではPowerShellの問題はおそらく構文/コマンドラインの解析に関連すると思われます。たぶんあなたが持っているエラーを投稿しますか? –

7

私はOPと同じ疑問を持っていました。アンディが投稿した答えはとても役に立ち、私を半分にしました。私は誰かが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) 
+0

上記の@Elijah W. Gagneさんが投稿したPSスクリプトを使用してDCOMを設定しようとしていますが、このオブジェクトで 'DACL'プロパティが見つからないというエラーが表示されています。エラーは、行 "$ sd.DACL = $ newDACL"です。私はPSの使い方にあまり精通していません。誰もが私がその仕事をするために何をする必要があるか教えてもらえますか?どうもありがとう! – RGuggisberg

+0

私は4行目まで実行します。そして、$ app変数を出力し、空でないことを確認してください(null)。そうであれば、おそらく4行目のWHERE句を調整する必要があります。 –

+0

バージョン12.0を使用していた11.0ではなく、$ appがnullであると私は変更しなければなりませんでした。しかし、私のために$ appdescを変更した後、スクリプトは魅力を発揮しました。 –

関連する問題