CredentialInfoEventArgs Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides data for an event handler regarding the acquisition of credentials.
public ref class CredentialInfoEventArgs sealed : System::ComponentModel::CancelEventArgs
public sealed class CredentialInfoEventArgs : System.ComponentModel.CancelEventArgs
type CredentialInfoEventArgs = class
inherit CancelEventArgs
Public NotInheritable Class CredentialInfoEventArgs
Inherits CancelEventArgs
- Inheritance
-
CredentialInfoEventArgs
Examples
The following example authenticates the user name and password.
void EditFeature(object sender, CredentialInfoEventArgs e) {
try {
e.Cancel = true;
using (new rWait()) {
string userName = String.Empty;
if (!String.IsNullOrEmpty(e.Credentials.UserName)) {
userName = e.Credentials.UserName;
}
string password = String.Empty;
if (!String.IsNullOrEmpty(e.Credentials.Password)) {
// If no username is set, but a password is, show an error
if (String.IsNullOrEmpty(userName)) {
IManagementUIService uiService =
(IManagementUIService)GetService(typeof(IManagementUIService));
Debug.Assert(uiService != null, "Couldn't get IManagementUIService.");
uiService.ShowError(null, "Invalid User Name",
"Authentication Failed", false);
return;
}
password = e.Credentials.Password;
}
_serviceProxy.SetAnonAuthen(userName, password);
e.Cancel = false;
_userName = userName;
_password = password;
}
} catch (Exception ex) {
MessageBox.Show(ex.Message, "EditFeature");
}
}
Remarks
Use this class to cancel events that require a CredentialInfo object.
Constructors
CredentialInfoEventArgs(CredentialInfo) |
Initializes a new instance of the CredentialInfoEventArgs class. |
Properties
Credentials |
Gets the credential information that is passed to the CredentialInfoEventArgs(CredentialInfo) constructor. |