473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CredUIPromptForWindowsCredentials

How do I use CredUIPromptForWindowsCredentials to validate logged on
credentials in a c# application running under Vista?
Sep 23 '07 #1
2 9019
"Dr. Paul Caesar - CoullByte (UK) Limited"
<Dr****************************@discussions.micros oft.comwrote in message
news:85**********************************@microsof t.com...
How do I use CredUIPromptForWindowsCredentials to validate logged on
credentials in a c# application running under Vista?


Don't know exactly why you want to use this for, but you'll have to PInvoke
this API (and some other)from credui.dll.
These API's are described in the Pltform SDK docs, check the wincred.h
header file for details on parameters and constants....

Following is a small sample to get you started...

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
struct _CREDUI_INFO
{
public int cbSize;
public IntPtr hwndParent;
public string pszMessageText;
public string pszCaptionText;
public IntPtr hbmBanner;
}
class Program
{
[DllImport("credui.dll", CharSet=CharSet.Unicode)]
internal static extern uint CredUIPromptForWindowsCredentials(ref
_CREDUI_INFO notUsedHere,
int authError,
ref uint authPackage,
IntPtr InAuthBuffer,
uint InAuthBufferSize,
out IntPtr refOutAuthBuffer,
out uint refOutAuthBufferSize,
ref bool fSave,
int flags);

const int CREDUIWIN_AUTHPACKAGE_ONLY = 0x10;
static void Main()
{
_CREDUI_INFO credui = new _CREDUI_INFO();
credui.cbSize = Marshal.SizeOf(credui);
credui.pszCaptionText = "Testje";
credui.pszMessageText = "Message";
uint authPackage = 0;
IntPtr outCredBuffer;
uint outCredSize;
bool save = false;

uint ret = CredUIPromptForWindowsCredentials(ref credui,
0,
ref authPackage,
IntPtr.Zero,
0,
out outCredBuffer,
out outCredSize,
ref save,
CREDUIWIN_AUTHPACKAGE_ONLY);

if(ret != 0)
// failed to load function...
...
else
// extract credentials from the buffer returned, using more
credui.dll API's .
...
}
....
Willy.
Sep 24 '07 #2
Thank you, this is what I was looking for, just need to configure it to
accept smart cards.

:)
Sep 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vijita | last post by:
I have enabled following policy on my Windows server 2008 : Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Credential User Interface\Require trusted path...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.