[英]TFS 2012 set Inheritance On recursively
Our Team Project permissions was previously managed in cluttery manner .我们的团队项目权限以前以混乱的方式管理。 Permission are directly given to specific files / sub folders.
权限直接授予特定文件/子文件夹。
Am trying to centralise all the permissions now.我现在正在尝试集中所有权限。 So i need to remove all the (explicit) specific permissions and make everything inherit from the parent folder.
所以我需要删除所有(显式)特定权限并使所有内容都从父文件夹继承。 Please see the image below.
请看下图。
I have also searched for tfs command line but found no answers!我也搜索了 tfs 命令行,但没有找到答案!
Is there quick way to do that?有没有快速的方法来做到这一点? (with the TFS web access, c#, tf command line)
(使用 TFS 网络访问、c#、tf 命令行)
The tf command can revoke the permissions: tf 命令可以撤销权限:
You can set these permissions in Team Foundation Server by right-clicking the server in Team Explorer, and then clicking Security.您可以通过在团队资源管理器中右键单击服务器,然后单击安全性,在 Team Foundation Server 中设置这些权限。 You can set these permissions by using the TFSSecurity command-line utility, except for those command-line utilities with a tf: designation.
您可以使用 TFSSecurity 命令行实用程序设置这些权限,但带有 tf: 标志的命令行实用程序除外。 For those with the tf: designation, use the Permission command of the tf command-line utility for source control to set the permissions.
对于具有 tf: 指定的用户,请使用源代码管理的 tf 命令行实用程序的 Permission 命令来设置权限。
For More ReferenceTFSSecurity Command-Line Utility Commands and Permission Command更多参考TFSSecurity 命令行实用程序命令和权限命令
Thanks to https://stackoverflow.com/a/10600473/2074346
感谢https://stackoverflow.com/a/10600473/2074346
and also to SoftwareCarpenter for giving me reference.
也给SoftwareCarpenter给我参考。
I found out about tf permission (Example: tf permission /inherit:yes itemSpec
).我发现了tf 权限(例如:
tf permission /inherit:yes itemSpec
)。 However, the /recursive switch doesn't work with it.但是, /recursive 开关不适用于它。 I guess I could write something that runs it recursively...
我想我可以写一些递归运行它的东西......
Edit: I finally got around to writing a tool for it:编辑:我终于开始为它编写一个工具:
static int Main(string[] args)
{
if (args.Length == 0 || args.Any(a => !a.StartsWith("$/")))
{
Console.WriteLine("Removes all explicit permissions and enables inheritance for a subtree.\n"
+ "Example: " + Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location) + " $/project/path1 $/project/path2");
return 3;
}
WorkspaceInfo wi = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory);
if (wi == null)
{
Console.WriteLine("Can't determine workspace for current directory: " + Environment.CurrentDirectory);
return 2;
}
var Tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(wi.ServerUri);
VersionControlServer VersionControlServer = Tfs.GetService<VersionControlServer>();
Console.WriteLine("Server: {0} Getting permissions...", wi.ServerUri);
ItemSecurity[] perms = VersionControlServer.GetPermissions(args, RecursionType.Full);
Console.WriteLine("Will remove explicit permissions from the following items:");
var changes = new List<SecurityChange>();
foreach (ItemSecurity perm in perms)
{
Console.WriteLine(" " + perm.ServerItem);
changes.Add(new InheritanceChange(perm.ServerItem, inherit: true));
foreach (AccessEntry e in perm.Entries)
{
changes.Add(new PermissionChange(perm.ServerItem, e.IdentityName, null, null, PermissionChange.AllItemPermissions));
}
}
Console.WriteLine("Enter to confirm:");
Console.ReadLine();
var successfulchanges = VersionControlServer.SetPermissions(changes.ToArray());
if (successfulchanges.Length == changes.Count)
{
Console.WriteLine("Explicit permissions removed from all items");
return 0;
}
else
{
Console.WriteLine("Explicit permissions removed only from:");
foreach (var c in successfulchanges)
{
Console.WriteLine(" " + c.Item);
}
return 1;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.