''' Windows Platform function (called via pInvoke) which populates an authentication buffer with authentication details.
''' See http://msdn.microsoft.com/en-us/library/aa374802(v=vs.85).aspx
''' <param name="dwFlags">RESERVED - must be zero.</param>
''' <param name="pszUserName">User Name.</param>
''' <param name="pszPassword">Password.</param>
''' <param name="pPackedCredentials">The buffer to be packed with credentials.</param>
''' <param name="pcbPackedCredentials">The the size of the buffer.</param>
''' <returns><c>True</c> on success; otherwise <c>False</c>. For extended error information, call the GetLastError() function.</returns>
<DllImport("credui.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> <CLSCompliant(False)> _
Public Shared Function CredPackAuthenticationBuffer(ByVal dwFlags As UInt32, ByVal pszUserName As String, ByVal pszPassword As String, ByVal pPackedCredentials As IntPtr, ByRef pcbPackedCredentials As UInt32) As <MarshalAs(UnmanagedType.Bool)> Boolean
Alternative Managed API:
Do you know one? Please contribute it!
Tips & Tricks:
To determine required buffer size, call first with pPackedCredentials = IntPtr.Zero. Should return error code 160, but pcbPackedCredentials will be populated with the expected buffer size. Use Marshal.AllocCoTaskMem() to allocate the appropriate buffer, then call again, this time passing the allocated buffer.
The CredPackAuthenticationBuffer function converts a string user name and password into an authentication buffer.
12/22/2012 6:58:45 AM - -126.96.36.199
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 11:00:13 AM - tsahi-188.8.131.52
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).