User Credentials CommandDialog with SecureString password
来源:互联网 发布:网络广播系统方案 编辑:程序博客网 时间:2024/05/16 06:46
Since I was working on authentication in a Winform client application, one of the common scenarios is “credential gathering”. This is typically a dialog that asks the user credentials when logging on to the application or accessing some restricted area of it.So I went back to get my UICredentialsHelper class in NCrypto project and not only ported to v2.0 but redesign it and added dome goodies as well. You can download the code from here. Let’s summarize its features:
- Shows up the standard Windows dialog for credential gathering (see CredUIPromptForCredentials API).
- Inherits from CommonDialog so it has a base standard API and IDE integration.
- Return the sensitive information like the user password in a SecureString type.
- Flexible to configure according to the features exposed by the CredUIPromptForCredentials API.
Sample Usage
Let’s see the basic usage of this dialog: using (CredentialsDialog dialog = new CredentialsDialog()){ if(dialog.ShowDialog() == DialogResult.OK) { // validate credentials against an authentication authority // ... // If credentials are valid // and the user checked the "remember my password" option if(dialog.SaveChecked) { dialog.ConfirmCredentials(true); } }}The “dialog.ShowDialog()” function call will show up the following dialog:
An interesting sample that you have included in the downloaded solution is the one that can run a process under the credentials account supplied.Let’s see the sample:
using (CredentialsDialog dialog = new CredentialsDialog()){ if (dialog.ShowDialog() == DialogResult.OK) { ProcessStartInfo info = newProcessStartInfo("notepad.exe"); info.UseShellExecute = false; info.UserName = dialog.User; info.Password = dialog.Password; info.Domain = dialog.Domain; using (Process install =Process.Start(info)) { install.WaitForExit(); Console.WriteLine(install.ExitCode); }}
}
As you can see, is pretty straightforward to use this dialog and you even can customize its appearance like changing its caption, text message, banner bitmat or event setting the user textbox as read only. Enjoy it!This posting is provided "AS IS" with no warranties, and confers no rights.
Referenced from: http://weblogs.asp.net/hernandl/archive/2005/11/21/usercredentialsdialog.aspx
- User Credentials CommandDialog with SecureString password
- Host Credentials报错"Connection to host as user oracle failed: ERROR: Wrong password for user"的解决一例
- Windows Gather User Credentials (phishing)
- alter database user password
- Unable to Save Credentials Password For Remote Desktop(RDP)
- rh333 - kinit(v5): Password incorrect while getting initial credentials
- Kerberos报错:kinit: Password incorrect while getting initial credentials
- mysql GRANT with ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO
- "MONGODB-CR credentials missing in the user document"的解决办法
- SecureString usage
- Using SecureString
- Oracle Default User/Password List
- Reset password for user SAP*
- Oracle user password has expired
- Enumerating Windows credentials with CredEnumerate function (Windows XP/2003 Only)
- Security Tutorials系列文章第六章:Validating User Credentials Against the Membership User Store
- Becoming an WPA Xpert Part 12: Timing User Login Credentials (Sometimes it IS the user)
- Programmatically add credentials to an ASMX Web Service that is password protected in C#
- 如何使K路归并外排序达到最优
- linux group
- Java 理论与实践: 线程池与工作队列
- 程序快捷方式管理软件LauncherV2_0_0使用手记
- WinCE OAL中的中断处理
- User Credentials CommandDialog with SecureString password
- wiki和blog的比较
- HP-UX查看版本
- 小甜饼cookie之精准投放
- 控制结构(一)
- 《我也有一个梦想》林达读后感
- AIX下errpt的使用
- CEC文件详解
- [解决网络出现“正在连接”的问题]