Example #1
0
        private void GetUserCreds(ProvisioningTemplateToolsConfiguration config, string projectFolderPath, string credsFilePath)
        {
            ProvisioningCredentials creds = null;

            //prompt for credentials then persist to .user xml file
            VSToolsConfigWindow cfgWindow = new VSToolsConfigWindow();

            cfgWindow.txtSiteUrl.Text  = config.Deployment.TargetSite;
            cfgWindow.txtUsername.Text = config.Deployment.Credentials.Username;
            cfgWindow.ShowDialog();

            bool saveNeeded = false;

            if (cfgWindow.DialogResult.HasValue && cfgWindow.DialogResult.Value)
            {
                config.Deployment.TargetSite = cfgWindow.txtSiteUrl.Text;
                creds = new ProvisioningCredentials()
                {
                    Username = cfgWindow.txtUsername.Text,
                };
                creds.SetSecurePassword(cfgWindow.txtPassword.Password);
                config.Deployment.Credentials = creds;

                saveNeeded = true;
            }

            if (saveNeeded)
            {
                //serialize the credentials to a file
                XmlHelpers.SerializeObject(config.Deployment.Credentials, credsFilePath);

                //save the config to a file
                SaveConfigForProject(projectFolderPath, config);

                //reset any cached sp contexts
                ProvisioningService.ResetSPContexts();
            }
        }
Example #2
0
        private void GetUserCreds(ProvisioningTemplateToolsConfiguration config, string projectFolderPath, string credsFilePath)
        {
            ProvisioningCredentials creds = null;

            //prompt for credentials then persist to .user xml file
            VSToolsConfigWindow cfgWindow = new VSToolsConfigWindow();
            cfgWindow.txtSiteUrl.Text = config.Deployment.TargetSite;
            cfgWindow.txtUsername.Text = config.Deployment.Credentials.Username;
            cfgWindow.ShowDialog();

            bool saveNeeded = false;
            if (cfgWindow.DialogResult.HasValue && cfgWindow.DialogResult.Value)
            {
                config.Deployment.TargetSite = cfgWindow.txtSiteUrl.Text;
                creds = new ProvisioningCredentials()
                {
                    Username = cfgWindow.txtUsername.Text,
                };
                creds.SetSecurePassword(cfgWindow.txtPassword.Password);
                config.Deployment.Credentials = creds;

                saveNeeded = true;
            }

            if (saveNeeded)
            {
                //serialize the credentials to a file
                XmlHelpers.SerializeObject(config.Deployment.Credentials, credsFilePath);

                //save the config to a file
                SaveConfigForProject(projectFolderPath, config);

                //reset any cached sp contexts
                ProvisioningService.ResetSPContexts();
            }
        }