我们的团队项目权限以前是以杂乱方式进行管理的。 权限直接授予特定文件/子文件夹。
我现在正试图集中所有权限。所以我需要删除所有(显式)特定权限,并使所有内容都从父文件夹继承。请看下面的图片。
我也搜索了tfs命令行,但没有找到答案!
有快速的方法吗? (使用TFS Web访问,c#,tf命令行)
答案 0 :(得分:2)
tf命令可以撤消权限:
答案 1 :(得分:0)
通过右键单击“团队资源管理器”中的服务器,然后单击“安全”,可以在Team Foundation Server中设置这些权限。您可以使用TFSSecurity命令行实用程序设置这些权限,但具有tf:指定的命令行实用程序除外。对于具有tf:指定的用户,请使用tf命令行实用程序的Permission命令进行源代码管理以设置权限。
更多参考TFSSecurity Command-Line Utility Commands and Permission Command
答案 2 :(得分:0)
感谢https://stackoverflow.com/a/10600473/2074346
以及SoftwareCarpenter给我参考。
我发现了tf permission(例如:tf permission /inherit:yes itemSpec
)。但是,/ recursive开关不能使用它。我想我可以写一些递归运行它的东西......
编辑:我终于开始为它编写工具了:
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;
}
}