如何从asp.net mvc应用程序传播身份以访问tfs服务器?

时间:2015-04-02 20:34:57

标签: asp.net-mvc authentication tfs asp.net-identity

我正在开发一个asp.net mvc应用程序来从TFS服务器中提取一些数据。

目前我在TFS服务器上遇到身份验证问题。当我从本地计算机运行应用程序时,一切正常,因为它将我的Windows身份传播到服务器,但是当我将应用程序部署到我的IIS8服务器时,由于没有用户登录,它将无法正常工作。

我想避免在IIS8服务器上使用Windows身份验证,因为我不想使用Windows组维护用户控件。相反,我只想在我的AD上验证用户,存储身份信息并将其传播到TFS服务器,但我对如何做到这一点毫无头绪。

你能帮助我吗?现在我的asp.net mvc应用程序没有身份验证,我收到以下消息:

    [UnauthorizedAccessException: Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio' is denied.]
   Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) +4325774
   Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions) +10872754
   Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options) +14
   Microsoft.VisualStudio.Services.Common.TokenStorage.RegistryTokenStorageHelper.GetRootKey(String subkeyName) +50
   Microsoft.VisualStudio.Services.Common.TokenStorage.RegistryTokenStorage.RetrieveToken(VssTokenKey tokenKey) +57
   Microsoft.VisualStudio.Services.Common.TokenStorage.VssTokenStorage.Retrieve(VssTokenKey tokenKey) +15
   Microsoft.TeamFoundation.Client.TfsClientCredentialStorage.RetrieveToken(Uri serverUrl, VssCredentialsType credentialType) +58
   Microsoft.TeamFoundation.Client.CookieCredential.OnCreateTokenProvider(Uri serverUrl, HttpWebResponse response) +127
   Microsoft.TeamFoundation.Client.IssuedTokenCredential.CreateTokenProvider(Uri serverUrl, HttpWebResponse response, IssuedToken failedToken) +45
   Microsoft.TeamFoundation.Client.TfsClientCredentials.TryGetTokenProvider(Uri serverUrl, IssuedTokenProvider& provider) +95
   Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestHelpers.PrepareWebRequest(HttpWebRequest webRequest, Guid sessionId, String operationName, CultureInfo cultureInfo, TfsRequestSettings settings, TfsClientCredentials credentials, IdentityDescriptor impersonate, IssuedToken& currentToken, IssuedTokenProvider& tokenProvider) +136
   Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestHelpers.CreateSoapRequest(Uri requestUri, Guid sessionId, String soapAction, String operationName, CultureInfo cultureInfo, TfsRequestSettings settings, TfsClientCredentials credentials, IdentityDescriptor impersonate, IssuedToken& currentToken, IssuedTokenProvider& tokenProvider) +106
   Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.CreateWebRequest() +154
   Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest() +599
   Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout) +243
   Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs) +91
   Microsoft.TeamFoundation.Framework.Client.LocationWebService.Connect(Int32 connectOptions, Int32 lastChangeId, Int32 features) +175
   Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.Connect(ConnectOptions connectOptions) +92
   Microsoft.TeamFoundation.Client.TfsConnection.EnsureProviderConnected() +723
   Microsoft.TeamFoundation.Client.TfsConnection.EnsureAuthenticated() +25

1 个答案:

答案 0 :(得分:1)

您的第一个问题是您需要在网络服务器的管理员下建立网站运行的帐户。目前的权限不会削减集合。

此外,您将遇到Kerberos的双跳认证问题(安全性很难),您需要为该帐户配置SPN以显示它以将Kerberos身份验证令牌代理到TFS服务器。用户SetSPN进行配置,您可能需要域管理员的帮助。