Esempio n. 1
0
        public override PSCredential PromptForCredential(string caption, string message, string userName,
                                                         string targetName, PSCredentialTypes allowedCredentialTypes,
                                                         PSCredentialUIOptions options)
        {
            try
            {
                if (_settings.PromptForCredentialsInConsole)
                {
                    return(PromptForCredentialFromConsole(caption, message, userName, targetName, allowedCredentialTypes,
                                                          options));
                }
            }
            catch
            {
            }

            IntPtr handle = _control.GetSafeWindowHandle();

            return(NativeUtils.CredUIPromptForCredential(
                       caption,
                       message,
                       userName,
                       targetName,
                       allowedCredentialTypes,
                       options,
                       handle));
        }
Esempio n. 2
0
        /// <summary>
        /// Prompts the user for credentials by using a specified prompt window caption,
        /// prompt message, user name and target name, credential types allowed to be
        /// returned, and UI behavior options. In this example this functionality
        /// is not needed so the method throws a NotImplementException exception.
        /// </summary>
        /// <param name="caption">The caption for the message window.</param>
        /// <param name="message">The text of the message.</param>
        /// <param name="userName">The user name whose credential is to be prompted for.</param>
        /// <param name="targetName">The name of the target for which the credential is collected.</param>
        /// <param name="allowedCredentialTypes">A PSCredentialTypes constant that
        /// identifies the type of credentials that can be returned.</param>
        /// <param name="options">A PSCredentialUIOptions constant that identifies the UI
        /// behavior when it gathers the credentials.</param>
        /// <returns>Throws a NotImplementedException exception.</returns>
        public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options)
        {
            IntPtr handle = _gui.GetSafeWindowHandle();

            return(NativeUtils.CredUIPromptForCredential(
                       caption,
                       message,
                       userName,
                       targetName,
                       allowedCredentialTypes,
                       options,
                       handle));
        }