Orc.NuGetExplorer.Native.CredUi.CredUnPackAuthenticationBuffer C# (CSharp) Method

CredUnPackAuthenticationBuffer() private method

private CredUnPackAuthenticationBuffer ( uint dwFlags, IntPtr pAuthBuffer, uint cbAuthBuffer, StringBuilder pszUserName, uint &pcchMaxUserName, StringBuilder pszDomainName, uint &pcchMaxDomainName, StringBuilder pszPassword, uint &pcchMaxPassword ) : bool
dwFlags uint
pAuthBuffer System.IntPtr
cbAuthBuffer uint
pszUserName StringBuilder
pcchMaxUserName uint
pszDomainName StringBuilder
pcchMaxDomainName uint
pszPassword StringBuilder
pcchMaxPassword uint
return bool
        public static extern bool CredUnPackAuthenticationBuffer(uint dwFlags, IntPtr pAuthBuffer, uint cbAuthBuffer, StringBuilder pszUserName, ref uint pcchMaxUserName, StringBuilder pszDomainName, ref uint pcchMaxDomainName, StringBuilder pszPassword, ref uint pcchMaxPassword);
        #endregion

Usage Example

        private void ManageCredentialsStorage(IntPtr outBuffer, uint outBufferSize, bool storedCredentials)
        {
            var  userName     = new StringBuilder(CredUi.CREDUI_MAX_USERNAME_LENGTH);
            var  password     = new StringBuilder(CredUi.CREDUI_MAX_PASSWORD_LENGTH);
            var  userNameSize = (uint)userName.Capacity;
            var  passwordSize = (uint)password.Capacity;
            uint domainSize   = 0;

            if (!CredUi.CredUnPackAuthenticationBuffer(0, outBuffer, outBufferSize, userName, ref userNameSize, null, ref domainSize, password, ref passwordSize))
            {
                throw Log.ErrorAndCreateException(x => new CredentialException(Marshal.GetLastWin32Error()),
                                                  "Failed to create the authentication buffer after prompting");
            }

            UserName = userName.ToString();
            Password = password.ToString();

            Log.Debug("User entered credentials with username '{0}'", UserName);

            if (!ShowSaveCheckBox)
            {
                return;
            }

            // If the NativeCredential was stored previously but the user has now cleared the save checkbox,
            // we want to delete the NativeCredential.
            if (storedCredentials && !IsSaveChecked)
            {
                DeleteCredential(Target);
            }

            if (IsSaveChecked)
            {
                WriteCredential(Target, UserName, Password);
            }
        }
All Usage Examples Of Orc.NuGetExplorer.Native.CredUi::CredUnPackAuthenticationBuffer