私たちは最近、世界中の途中で新しいドメインサーバーに移動することを余儀なくされました。これはそれほど大きな変化ではないように思われるかもしれませんが、頻繁に実行するプロセスの1つが、突然2秒のコマンドから5分のコマンドになりました。
理由?「テンプレート」ディレクトリ構造に基づいて、多くのディレクトリのアクセス許可を更新しています。
XCOPYは、同じ古い2秒のウィンドウでこれらの設定の大部分を更新できることを発見しました。もちろん、残りの設定は省略されます。
私が理解しようとしているのは、XCopyが.NETセキュリティクラスがネイティブに実行する必要があることをどのように高速化できるかということです。明らかに私は何かが欠けています。
ドメイン/ActiveDirectoryサーバーにping(または最小限のping)を実行せずにディレクトリのACL情報をコピーするための最良の方法は何ですか?
これが私が持っているものです:
...
DirectorySecurity TemplateSecurity = new DirectorySecurity(TemplateDir, AccessControlSections.All);
...
public static void UpdateSecurity(string destination, DirectorySecurity TemplateSecurity)
{
DirectorySecurity dSecurity = Directory.GetAccessControl(destination);
// Remove previous security settings. (We have all we need in the other TemplateSecurity setting!!)
AuthorizationRuleCollection acl_old = dSecurity.GetAccessRules(true, true, typeof(NTAccount));
foreach (FileSystemAccessRule ace in acl_old)
{
// REMOVE IT IF YOU CAN... if you can't don't worry about it.
try
{
dSecurity.RemoveAccessRule(ace);
}
catch { }
}
// Remove the inheritance for the folders...
// Per the business unit, we must specify permissions per folder.
dSecurity.SetAccessRuleProtection(true, true);
// Copy the permissions from TemplateSecurity to Destination folder.
AuthorizationRuleCollection acl = TemplateSecurity.GetAccessRules(true, true, typeof(NTAccount));
foreach (FileSystemAccessRule ace in acl)
{
// Set the existing security.
dSecurity.AddAccessRule(ace);
try
{
// Remove folder inheritance...
dSecurity.AddAccessRule(new FileSystemAccessRule(
ace.IdentityReference, ace.FileSystemRights,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
ace.AccessControlType));
}
catch { }
}
// Apply the new changes.
Directory.SetAccessControl(destination, dSecurity);
}