locked
Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio' is denied. RRS feed

  • Question

  • Hello,

    I am using VS 2013 to create a solution in SharePoint 2013 to access the TFS 2013 WIT. When I want to make a connection to the TFSStore I get following error: Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VSCommon\12.0\ClientServices\TokenStorage\VisualStudio' is denied.

    This is my code:

    public static bool ValidateTFSConnection(string TfsConnectionURL, SecureStoreCredentialCollection TfsUser, out string errormessage) { errormessage = null; WorkItemStore wistore = null; try { wistore = ConnectToTFS(TfsConnectionURL, TfsUser); } catch(Exception ex) { errormessage = ex.Message; } return (wistore != null ? true : false); }

     static WorkItemStore ConnectToTFS(string TFSConnectionURL, SecureStoreCredentialCollection TfsUser)
            {
                TfsTeamProjectCollection tfs;
                
                if (TfsUser == null) 
              
                {
                    //Uri uri = new Uri("http://tempuri.org/");
                    //ICredentials credentials = CredentialCache.DefaultCredentials;
                    //NetworkCredential cred = credentials.GetCredential(uri, "Basic");
                    //NetworkCredential cred = CredentialCache.DefaultNetworkCredentials;
                    tfs = new TfsTeamProjectCollection(new Uri(TFSConnectionURL), System.Net.CredentialCache.DefaultNetworkCredentials);
                    //tfs = new TfsTeamProjectCollection(new Uri(TFSConnectionURL)); //, cred);
                }
                else
                {
                    string user = DecryptSecureString(TfsUser.First(x => x.CredentialType == SecureStoreCredentialType.WindowsUserName).Credential);
                    string pass = DecryptSecureString(TfsUser.First(x => x.CredentialType == SecureStoreCredentialType.WindowsPassword).Credential);
    
                    tfs = new TfsTeamProjectCollection(new Uri(TFSConnectionURL), new NetworkCredential(user, pass));
                }
    
                    /*case 1:
                        if (HttpContext.Current == null) return null;
                        var baseUserTpcConnection = new TfsTeamProjectCollection(new Uri(TFSConnectionURL));
                        var ims = baseUserTpcConnection.GetService<IIdentityManagementService>();
    
                        var identity = ims.ReadIdentity(
                                IdentitySearchFactor.AccountName,
                                HttpContext.Current.User.Identity.Name,
                                MembershipQuery.None,
                                ReadIdentityOptions.None);
    
                        tfsCred = identity.Descriptor;
                        tfs = new TfsTeamProjectCollection(new Uri(TFSConnectionURL), tfsCred as IdentityDescriptor);
                        break;*/
                tfs.EnsureAuthenticated();
                
                var wistore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
    
                //Log("ConnectToTFS", TFSConnectionURL);
    
                return wistore;
            }
    

    tfs.EnsureAuthenticated(); is the part that returns the exception.

    Ronald.


    Ronald Put

    Thursday, February 6, 2014 2:40 PM

Answers

  • Hi,

    try running your Visual Studio in Administrator Mode.


    Regards, Preetam Ramdhave

    • Marked as answer by Ronald Put Tuesday, April 1, 2014 12:33 PM
    Friday, February 7, 2014 9:50 AM

All replies

  • Hi,

    try running your Visual Studio in Administrator Mode.


    Regards, Preetam Ramdhave

    • Marked as answer by Ronald Put Tuesday, April 1, 2014 12:33 PM
    Friday, February 7, 2014 9:50 AM
  • That's a good one... Going to try that.

    That should help.


    Ronald Put

    Wednesday, February 12, 2014 10:06 AM
  • hi, i have a similar scenario. want to create a TFS interface on SP site. and i am trying make a connection to tfs user from AD, i couldnt find a way to SecureStoreCredentialCollection dll file ref. dose this param comes from the dell file?

    Monday, April 28, 2014 3:11 PM