嗨,我正在尝试通过 TFS API 创建新的工作项,这是我在下面用来获取可以分配工作项的有效用户列表的方法。不知何故,它在 validUserSids 行上给了我一个空引用异常。有人知道这里有什么问题吗?
private string[] TFSUsers(string server)
{
// Get a Reference to Team Foundation Server.
TeamFoundationServer tfs = tfsdata.GetTFS(server);
// Get a reference to Group Security Service.
IGroupSecurityService gss = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService));
// Resolve to SIDs
Identity validUserSids = gss.ReadIdentity(SearchFactor.AccountName, "TFS Valid Users", QueryMembership.Expanded);
// Resolve to actual users
Identity[] validUsers = gss.ReadIdentities(SearchFactor.Sid, validUserSids.Members, QueryMembership.None);
List<string> Users = new List<string>();
foreach (Identity user in validUsers)
{
Users.Add(user.DisplayName);
}
return Users.ToArray();
}