如何列出不再属于任何安全组的旧 TFS 用户?

发布于 2024-12-19 05:37:52 字数 714 浏览 5 评论 0原文

有很多示例展示了如何获取当前 TFS 用户的列表,但是如何获取过去已提交更改但不再属于任何安全组的旧用户列表?

作为记录,这是我用来查找所有当前用户的代码:

var gss = tfs.GetService<IGroupSecurityService>();
var members = gss.ReadIdentity(SearchFactor.EveryoneApplicationGroup,
                               null,
                               QueryMembership.Expanded).Members;
return gss.ReadIdentities(SearchFactor.Sid, members, QueryMembership.None)
    .Where(identity => identity != null &&
                       identity.Type == IdentityType.WindowsUser)
    .Select(identity => string.Format(@"{0}\{1}",
                                      identity.Domain,
                                      identity.AccountName));

There are lots of examples around that show how to get a list of current TFS users, but how do I get a list of old users that have commit changes in the past but no longer belong to any security groups?

For the record, this is the code I'm using to find all current users:

var gss = tfs.GetService<IGroupSecurityService>();
var members = gss.ReadIdentity(SearchFactor.EveryoneApplicationGroup,
                               null,
                               QueryMembership.Expanded).Members;
return gss.ReadIdentities(SearchFactor.Sid, members, QueryMembership.None)
    .Where(identity => identity != null &&
                       identity.Type == IdentityType.WindowsUser)
    .Select(identity => string.Format(@"{0}\{1}",
                                      identity.Domain,
                                      identity.AccountName));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

这样的小城市 2024-12-26 05:37:52

我无法提供确切的答案,但希望这会有所帮助...

您可以通过工作区(即 tf.exe 工作区命令和等效 api)列出所有待处理的更改。使用每个工作区的所有者以及未提交的更改,您应该能够交叉引用您已经拥有的活动用户列表。

I can't offer an exact answer, but hopefully this will help...

You can list all pending changes through the workspaces (i.e. tf.exe workspaces command and equivalent apis). Using the owner of each workspace with uncommitted changes you should then be able to cross-reference against the list of active users you've already got.

回忆那么伤 2024-12-26 05:37:52

以下代码片段应该揭示曾经在 TeamCollection 存储库中提交更改的每个人:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace PeopleWhoHaveCommitedChangesets
{
    class Program
    {
        static void Main()
        {
            TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSServer:8080"));
            VersionControlServer vcs = (VersionControlServer) tpc.GetService(typeof (VersionControlServer));
            IEnumerable results = vcs.QueryHistory(@"$/",
                                                    VersionSpec.Latest, 0, RecursionType.Full, null, null, null, int.MaxValue, true, true);
            List<Changeset> changesets = results.Cast<Changeset>().ToList();

            List<string> Users = new List<string>();
            foreach (var changeset in changesets)
            {
                if(!Users.Contains(changeset.Owner))
                {
                    Users.Add(changeset.Owner);
                }
            }
        }
    }
}

请注意,这是一种蛮力,并且由于存在大量更改集,因此需要相当长的时间来执行。

The following snippet should reveal each and every person that has ever committed changes in your TeamCollection repository:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace PeopleWhoHaveCommitedChangesets
{
    class Program
    {
        static void Main()
        {
            TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSServer:8080"));
            VersionControlServer vcs = (VersionControlServer) tpc.GetService(typeof (VersionControlServer));
            IEnumerable results = vcs.QueryHistory(@"$/",
                                                    VersionSpec.Latest, 0, RecursionType.Full, null, null, null, int.MaxValue, true, true);
            List<Changeset> changesets = results.Cast<Changeset>().ToList();

            List<string> Users = new List<string>();
            foreach (var changeset in changesets)
            {
                if(!Users.Contains(changeset.Owner))
                {
                    Users.Add(changeset.Owner);
                }
            }
        }
    }
}

Beware that this is a brute force, and, with a lot of changesets, it would take considerable time to execute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文