アップグレードしている小さなデプロイツールがあります。このツールは、ビルドボックスからコードのバージョンを取得し、SVNを更新してから、Xサーバーに配置します(配置により、配置インストールの特定の部分がスタック内の別のサーバーに移動されます)。
現在起こっていることは、ビルドボックス以外で実行された場合、セキュリティのために機能しません。
私たちのビルドボックスは内部にあり、私たち自身のドメインにあります。コピー先のサーバーは、高セキュリティドメイン上にあります。ここで説明する手法を使用しました:C#のWindowsでパスワードで保護されたネットワークドライブにアクセスしますか?それらのドメインドライブ上のファイル/データにアクセスするため、マップする必要はありません。
しかし、ここに問題があります。
ビルドボックス-ドメインA
サーバーの展開-ドメインBサーバーの展開2-ドメインB
開発者は管理者として実行され、ドメイン上にあるため、私のボックスはビルドボックスを完全に制御できます。ただし、ログインを偽装してドメインBにアクセスすると、ドメインAビルドボックスにアクセスできなくなります。
これは内部ユーティリティであり、助けていただければ幸いです。
*コピーする代わりにこれに関する広範な作業がある場合は、新しいスレッドを開き、コマンドラインを実行して、コピーする代わりに可能性があるため、各サーバーのSVNからこれらのファイルを取得できます。すべてのデプロイインストールファイルをSVNに保持します。
IntPtr token;
if (!Security.Access.LogonUser("ChuckNorris", "a_small_bunny[0]", "OfficeSpace", Security.Enums.LogonType.NewCredentials, Security.Enums.LogonProvider.Default, out token))
{
throw new Win32Exception();
}
try
{
IntPtr dToken;
if (!Security.Access.DuplicateToken(token, Security.Enums.SecurityImpersonationLevel.Impersonation, out dToken))
throw new Win32Exception();
try
{
using (WindowsImpersonationContext iContext = new WindowsIdentity(dToken).Impersonate())
{
Directory.CreateDirectory(destDir); //Works Here as I have impersonation
// copy each file to destination
//This will bomb as my user is now linked to the prod domain.
foreach (string file in Directory.GetFiles(srcDir))
{
// update property bag
UpdatePropertyBag(
propertyBag,
PropertyBag.Step,
"Copying [" + file + "] to [" + destDir + "]");
// copy each file
File.Copy(file, CombinePath(destDir, Path.GetFileName(file)));
}
// deal with each file/folder
foreach (string dir in Directory.GetDirectories(srcDir))
{
// copy each subdirectory
CopyDirectory(propertyBag, srcDir, destDir, Path.GetFileName(dir));
}
iContext.Undo();
}
}
catch (Exception ex)
{
}
finally
{
if (dToken != IntPtr.Zero)
{
if (!Security.Access.CloseHandle(dToken))
{
// Uncomment if you need to know this case.
////throw new Win32Exception();
}
}
}
}
catch (Exception ex)
{
}
finally
{
if (token != IntPtr.Zero)
{
if (!Security.Access.CloseHandle(token))
{
// Uncomment if you need to know this case.
////throw new Win32Exception();
}
}
}