Ejemplo n.º 1
0
        public async Task <NetworkCredential> GenerateCredentialsAsync(
            IWin32Window owner,
            InstanceLocator instanceRef,
            string suggestedUsername = null)
        {
            // Prompt for username to use.
            var username = new GenerateCredentialsDialog().PromptForUsername(
                owner,
                suggestedUsername ?? this.authService.Authorization.SuggestWindowsUsername());

            if (username == null)
            {
                return(null);
            }

            var credentials = await this.jobService.RunInBackground(
                new JobDescription("Generating Windows logon credentials..."),
                token => this.computeEngineAdapter.ResetWindowsUserAsync(
                    instanceRef,
                    username,
                    token));

            new ShowCredentialsDialog().ShowDialog(
                owner,
                credentials.UserName,
                credentials.Password);

            return(credentials);
        }
Ejemplo n.º 2
0
        public async Task GenerateCredentialsAsync(
            IWin32Window owner,
            InstanceLocator instanceLocator,
            ConnectionSettingsEditor settings,
            string suggestedUsername = null)
        {
            // Prompt for username to use.
            var username = new GenerateCredentialsDialog().PromptForUsername(
                owner,
                suggestedUsername ?? this.authService.Authorization.SuggestWindowsUsername());

            if (username == null)
            {
                // Aborted.
                throw new OperationCanceledException();
            }

            var credentials = await this.jobService.RunInBackground(
                new JobDescription("Generating Windows logon credentials..."),
                token => this.computeEngineAdapter.ResetWindowsUserAsync(
                    instanceLocator,
                    username,
                    token))
                              .ConfigureAwait(true);

            new ShowCredentialsDialog().ShowDialog(
                owner,
                credentials.UserName,
                credentials.Password);

            // Save credentials.
            settings.Username          = credentials.UserName;
            settings.CleartextPassword = credentials.Password;
            settings.Domain            = null;
            settings.SaveChanges();
        }