コード例 #1
0
ファイル: CredentialsDialog.cs プロジェクト: waie123/GitMind
        public bool Delete()
        {
            if (string.IsNullOrEmpty(Target))
            {
                throw new InvalidOperationException("Target must be specified to delete a credential.");
            }

            StringBuilder target = string.IsNullOrEmpty(Target) ? new StringBuilder() : new StringBuilder(Target);
            bool          result = CREDUI.CredDelete(target, CREDUI.CredentialType.Generic, 0);

            return(result);
        }
コード例 #2
0
ファイル: CredentialsDialog.cs プロジェクト: waie123/GitMind
        /// <summary>Returns a DialogResult indicating the user action.</summary>
        /// <param name="owner">The System.Windows.Forms.IWin32Window the dialog will display in front of.</param>
        /// <remarks>
        /// Sets the name, password and SaveChecked accessors to the state of the dialog as it was dismissed by the user.
        /// </remarks>
        private DialogResult ShowDialog(IWin32Window owner)
        {
            // set the api call parameters
            StringBuilder name = new StringBuilder(CREDUI.MAX_USERNAME_LENGTH);

            name.Append(this.Name);

            StringBuilder password = new StringBuilder(CREDUI.MAX_PASSWORD_LENGTH);

            password.Append(this.Password);

            int saveChecked = Convert.ToInt32(this.SaveChecked);

            CREDUI.INFO  info  = GetInfo(owner);
            CREDUI.FLAGS flags = GetFlags();

            // make the api call
            CREDUI.ReturnCodes code = CREDUI.PromptForCredentials(
                ref info,
                this.Target,
                IntPtr.Zero, 0,
                name, CREDUI.MAX_USERNAME_LENGTH,
                password, CREDUI.MAX_PASSWORD_LENGTH,
                ref saveChecked,
                flags
                );

            // clean up resources
            if (this.Banner != null)
            {
                GDI32.DeleteObject(info.hbmBanner);
            }

            // set the accessors from the api call parameters
            this.Name        = name.ToString();
            this.Password    = password.ToString();
            this.SaveChecked = Convert.ToBoolean(saveChecked);

            return(GetDialogResult(code));
        }
コード例 #3
0
ファイル: CredentialsDialog.cs プロジェクト: waie123/GitMind
        /// <summary>Confirmation action to be applied.</summary>
        /// <param name="value">True if the credentials should be persisted.</param>
        public void Confirm(bool value)
        {
            CREDUI.ReturnCodes confirmCredentials = CREDUI.ConfirmCredentials(this.Target, value);

            switch (confirmCredentials)
            {
            case CREDUI.ReturnCodes.NO_ERROR:
                break;

            case CREDUI.ReturnCodes.ERROR_INVALID_PARAMETER:
                // for some reason, this is encountered when credentials are overwritten
                break;

            case CREDUI.ReturnCodes.ERROR_NOT_FOUND:
                // for some reason, this is encountered when dialog was not shown
                break;


            default:
                throw new ApplicationException("Credential confirmation failed. " + confirmCredentials);
            }
        }