我有一個我正在升級的小型部署工具。該工具從構建框中獲取代碼版本,更新SVN,然後將其放置在X服務器上(部署將特定部署的部署安裝到堆棧中的不同服務器上)。在不在同一個域中的2個受保護源之間複製文件
現在發生的事情是,當它在我們的構建箱以外的任何地方運行時,它不會因爲證券而起作用。
我們的構建箱是內部的,在我們自己的領域。我們正在複製的服務器位於高安全性域。我已經使用了這裏解釋的技術:Accessing Password Protected Network Drives in Windows in C#?訪問這些域驅動器上的文件/數據,所以我不需要映射它。
但是,這裏有一個問題。
構建箱 - 域A
部署服務器 - 域B 部署服務器2 - 域B
我的盒子已經在我們構建盒完全控制,因爲開發的運行作爲管理員,這是對我們的域。但是,一旦我模擬登錄,所以我在域B上,我無法訪問我的域構建框。
這是一個內部工具,任何幫助,將不勝感激。
*如果在這方面做了大量工作,而不是複製,我可以打開新線程並運行命令行到從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();
}
}
}