我试过两种方式连接到我们正在运行的TFS服务器的workitemstore。尝试A将连接到配置服务器并使用GetService<WorkItemStore>()
方法。这总是返回null。如何成功连接到TFS 2010 workitem商店?
尝试B连接到TfsTeamProjectCollection,并使用GetService<WorkItemStore>()
方法或将项目集合传递给WorkItemStore构造函数。在尝试B上,我收到一个异常,指出“错误HRESULT E_FAIL已从调用COM组件返回。”我能找到的唯一信息似乎表明有一些权限问题,但我已确认我是通过对整个项目集合的读取权限进行身份验证的,并且我通过VS 2011 dev预览进行了适当的连接和干预。
这里是我如何连接?
public TfsConfigurationServer GetConfigurationServer()
{
Uri tfsUri = new Uri(configs.TfsUri);
TfsConfigurationServer server = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri, credProvider);
server.Authenticate();
if (server.HasAuthenticated == false)
throw new InvalidOperationException("You can't authenticate against the tfs instance.");
return server;
}
public TfsTeamProjectCollection GetProjectCollectionInstance(string projectCollectionName)
{
Uri tfsUri = new Uri(configs.TfsUri + "/" + projectCollectionName);
TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri, credProvider);
collection.Authenticate();
if (collection.HasAuthenticated == false)
throw new InvalidOperationException("You can't authenticate against the tfs instance.");
return collection;
}
和这里的如何,我试图让WorkItemStore(愚蠢的代码来说明问题)......
public WorkItemProvider()
{
if (workItems == null)
workItems = ServerProvider.ServerInstance.GetService<WorkItemStore>();
if (workItems == null)
workItems = ServerProvider.ProjectCollectionInstance.GetService<WorkItemStore>();
if (workItems == null)
workItems = new WorkItemStore(ServerProvider.ProjectCollectionInstance);
if (workItems == null)
throw new NullReferenceException("Couldn't load work item store.");
}
我与服务器不在同一个域中,但是我使用ICredentialsProvider作为域用户进行身份验证,并且我确认我已通过该用户的身份验证。任何指针都会有帮助。
附加信息:相同的代码在我们的域中使用Windows身份验证和模拟的计算机上正常工作。我想我不能从域外做到这一点?我可以从Visual Studio中,所以没有任何意义。也许如果我可以冒充域用户,即使我不在域上? – sonicblis 2012-02-07 00:23:57