【问题标题】:How to Grant Read-Only Access to All TFS Team Projects to a Group of Users?如何向一组用户授予对所有 TFS 团队项目的只读访问权限?
【发布时间】:2011-11-01 01:55:18
【问题描述】:

我从How to add Windows group as "Readers" to all projects in TFS 2010 collection? 的回答中看到,这必须对所有现有项目手动完成。

是否有可用于执行此操作的命令行工具?我知道TfsSecurity 计划,但我为单个团队项目执行此操作的尝试没有奏效。


我为单个团队项目做了什么:

  1. 我创建了“[DefaultCollection]\All Project Read-Only Users”作为集合级组,其中包含一个 Active Directory 组作为成员。
  2. 然后我尝试为该组添加对项目的读取权限:

tfssecurity /collection:http://tfs:8080/tfs/defaultcollection /a+ Project vstfs:///Classification/TeamProject/guid GENERIC_READ "[DefaultCollection]\All Project Read-Only Users" 允许

这确实为团队项目添加了该组的 ACL,但该组没有出现在团队项目的安全对话框中。

我想做的是为该组授予与团队项目的“读者”组相同的访问权限。

【问题讨论】:

标签: security tfs


【解决方案1】:

这是一个 powershell 脚本,用于遍历集合中的每个团队项目,获取 Readers 组并添加 SID。

# load the required dll
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")

function get-tfs
{
    param(
    [string] $serverName = $(throw 'serverName is required')
    )

    $propertiesToAdd = (
        ('VCS', 'Microsoft.TeamFoundation.VersionControl.Client', 'Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer'),
        ('WIT', 'Microsoft.TeamFoundation.WorkItemTracking.Client', 'Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore'),
        ('CSS', 'Microsoft.TeamFoundation', 'Microsoft.TeamFoundation.Server.ICommonStructureService'),
        ('GSS', 'Microsoft.TeamFoundation', 'Microsoft.TeamFoundation.Server.IGroupSecurityService')
    )

    [psobject] $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
    foreach ($entry in $propertiesToAdd) {
        $scriptBlock = '
            [System.Reflection.Assembly]::LoadWithPartialName("{0}") > $null
            $this.GetService([{1}])
        ' -f $entry[1],$entry[2]
        $tfs | add-member scriptproperty $entry[0] $ExecutionContext.InvokeCommand.NewScriptBlock($scriptBlock)
    }
    return $tfs
}
#set the TFS server url
[psobject] $tfs = get-tfs -serverName http://YourTfsServer:8080/tfs/YourColleciton


$items = $tfs.vcs.GetAllTeamProjects( 'True' )
    $items | foreach-object -process { 
    $proj = $_
    $readers = $tfs.GSS.ListApplicationGroups($proj.Name) | ?{$_.DisplayName -eq 'Readers' }

    $tfs.GSS.AddMemberToApplicationGroup($readers.Sid, 'TheSidToTheGroupYouWantToAdd')
}

【讨论】:

    【解决方案2】:

    我的方法是基于以下事实:除非明确拒绝,否则 TFS 权限是继承的。

    要创建一个以只读权限自动访问所有现有项目以及未来项目的用户组,请执行以下步骤:

    1. 在项目集合级别创建一个新的安全组。您可以在 Visual Studio 中使用“团队/团队项目集合设置/组成员资格”菜单进行操作。

    2. 将新组添加为“项目集合管理员”组的成员。这将授予对集合中所有项目的访问权限,包括期货项目。

    3. 限制新组的权限以移除继承的管理员权限。要强制只读访问,请拒绝除“创建工作区”、“查看构建资源”和“查看集合级信息”之外的所有权限。

    该组的用户将拥有对集合中所有项目的源代码、工作项和构建定义的读取权限。

    【讨论】:

    • 我刚刚尝试过,但无法让它为我工作。不知道我做错了什么。
    • @Peter 我刚刚在 TFS 2017 上试过这个,它可以工作。在不知道您尝试了什么的情况下,我不可能告诉您为什么它不起作用。严格按照步骤操作?有趣的是,已经有一个组具有“只读”访问权限(有效用户),但该组本身是“只读”的。通过执行这些步骤,您基本上是在创建一个可修改的“有效用户”组。
    • @Gustavo,我刚刚尝试过,但是这种方法为该用户提供了管理员权限,即使我拒绝了除您提到的那些特权之外的所有特权。 (Azure Devops Server 2019)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-03
    • 2020-09-27
    • 2022-10-21
    • 2018-05-24
    • 1970-01-01
    相关资源
    最近更新 更多