CredUICredUnPackAuthenticationBuffer(CredentialsPackFlags, IntPtr, Int32, IntPtr, Int32, IntPtr, Int32, IntPtr, Int32) Method

Converts an authentication buffer returned by a call to the CredUIPromptForWindowsCredentials(CredUiInfo, Win32ErrorCode, UInt32, IntPtr, UInt32, IntPtr, UInt32, Boolean, WindowsCredentialsDialogOptions) function into a string user name and password.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("CredUI.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static bool CredUnPackAuthenticationBuffer(
	CredentialsPackFlags flags,
	IntPtr authBuffer,
	int authBufferSize,
	IntPtr userName,
	ref int refUserNameSize,
	IntPtr domainName,
	ref int refDomainNameSize,
	IntPtr password,
	ref int refPasswordSize
)

Parameters

flags  CredentialsPackFlags
Setting the value of this parameter to CRED_PACK_PROTECTED_CREDENTIALS specifies that the function attempts to decrypt the credentials in the authentication buffer. If the credential cannot be decrypted, the function returns , and a call to the GetLastError function will return the value ERROR_NOT_CAPABLE.

How the decryption is done depends on the format of the authentication buffer.

If the authentication buffer is a SEC_WINNT_AUTH_IDENTITY_EX2 structure, the function can decrypt the buffer if it is encrypted by using SspiEncryptAuthIdentityEx with the SEC_WINNT_AUTH_IDENTITY_ENCRYPT_SAME_LOGON option.

If the authentication buffer is one of the marshaled KERB_*_LOGON structures, the function decrypts the password before returning it in the password buffer.

authBuffer  IntPtr
A pointer to the authentication buffer to be converted.

This buffer is typically the output of the CredUIPromptForWindowsCredentials(CredUiInfo, Win32ErrorCode, UInt32, IntPtr, UInt32, IntPtr, UInt32, Boolean, WindowsCredentialsDialogOptions) or CredPackAuthenticationBuffer(CredentialsPackFlags, String, String, IntPtr, Int32) function.

authBufferSize  Int32
The size, in bytes, of the authBuffer buffer.
userName  IntPtr
A pointer to a null-terminated string that receives the user name.

This string can be a marshaled credential.

refUserNameSize  Int32
A pointer to a value that specifies the size, in characters, of the userName buffer.

On output, if the buffer is not of sufficient size, specifies the required size, in characters, of the userName buffer. The size includes terminating null character.

domainName  IntPtr
A pointer to a null-terminated string that receives the name of the user's domain.
refDomainNameSize  Int32
A pointer to a value that specifies the size, in characters, of the domainName buffer.

On output, if the buffer is not of sufficient size, specifies the required size, in characters, of the domainName buffer. The size includes the terminating null character.

The required size can be zero if there is no domain name.

password  IntPtr
A pointer to a null-terminated string that receives the password.
refPasswordSize  Int32
A pointer to a value that specifies the size, in characters, of the password buffer. On output, if the buffer is not of sufficient size, specifies the required size, in characters, of the password buffer. The size includes the terminating null character. This string can be a marshaled credential.

Return Value

Boolean
if the function succeeds; otherwise, .

Remarks

See Also