Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

CredUIPromptForWindowsCredentials

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dr. Paul Caesar - CoullByte (UK) Limited - 23 Sep 2007 22:54 GMT
How do I use CredUIPromptForWindowsCredentials to validate logged on
credentials in a c# application running under Vista?
Willy Denoyette [MVP] - 24 Sep 2007 12:34 GMT
> 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.
Paul C. Caesar - 24 Sep 2007 12:48 GMT
Thank you, this is what I was looking for, just need to configure it to
accept smart cards.

:)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.