【问题标题】:TFS 2012 set Inheritance On recursivelyTFS 2012 递归设置继承
【发布时间】:2015-12-11 09:47:38
【问题描述】:

我们的团队项目权限以前以杂乱无章的方式进行管理。 直接授予特定文件/子文件夹的权限。

我现在正在尝试集中所有权限。所以我需要删除所有(显式)特定权限并使所有内容都从父文件夹继承。请看下图。

我也搜索过 tfs 命令行但没有找到答案!

有没有快速的方法来做到这一点? (使用 TFS 网络访问、c#、tf 命令行)

【问题讨论】:

标签: c# .net command-line tfs


【解决方案1】:

感谢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;
    }
}

【讨论】:

    【解决方案2】:

    您可以通过在 Team Explorer 中右键单击服务器,然后单击“安全”来在 Team Foundation Server 中设置这些权限。您可以使用 TFSSecurity 命令行实用程序设置这些权限,但带有 tf: 名称的命令行实用程序除外。对于具有 tf: 名称的用户,请使用用于源代码控制的 tf 命令行实用程序的 Permission 命令来设置权限。

    更多参考TFSSecurity Command-Line Utility Commands and Permission Command

    【讨论】:

      【解决方案3】:

      tf命令可以撤销权限:

      tf command

      【讨论】:

      • tf 权限 /remove:* /group:developers $/baseobjects
      猜你喜欢
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-18
      • 1970-01-01
      • 2017-12-23
      • 1970-01-01
      • 2022-11-27
      相关资源
      最近更新 更多