ServiceCredentials.UserNameAuthentication Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient les paramètres actuels d'authentification par nom d'utilisateur/mot de passe pour ce service.
public:
property System::ServiceModel::Security::UserNamePasswordServiceCredential ^ UserNameAuthentication { System::ServiceModel::Security::UserNamePasswordServiceCredential ^ get(); };
public System.ServiceModel.Security.UserNamePasswordServiceCredential UserNameAuthentication { get; }
member this.UserNameAuthentication : System.ServiceModel.Security.UserNamePasswordServiceCredential
Public ReadOnly Property UserNameAuthentication As UserNamePasswordServiceCredential
Valeur de propriété
Instance de UserNamePasswordServiceCredential.
Exemples
Le code suivant indique comment utiliser cette propriété pour obtenir l'instance des informations d'identification utilisées par le service.
// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);
// Create a binding that uses a username/password credential.
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
// Add an endpoint.
sh.AddServiceEndpoint(typeof(ICalculator), b, "UserNamePasswordCalculator");
// Get a reference to the UserNamePasswordServiceCredential object.
UserNamePasswordServiceCredential unpCredential =
sh.Credentials.UserNameAuthentication;
// Print out values.
Console.WriteLine("IncludeWindowsGroup: {0}",
unpCredential.IncludeWindowsGroups);
Console.WriteLine("UserNamePasswordValidationMode: {0}",
unpCredential.UserNamePasswordValidationMode);
Console.WriteLine("CachedLogonTokenLifetime.Minutes: {0}",
unpCredential.CachedLogonTokenLifetime.Minutes );
Console.WriteLine("CacheLogonTokens: {0}",
unpCredential.CacheLogonTokens );
Console.WriteLine("MaxCachedLogonTokens: {0}",
unpCredential.MaxCachedLogonTokens );
Console.ReadLine();
' Create a service host.
Dim httpUri As New Uri("http://localhost/Calculator")
Dim sh As New ServiceHost(GetType(Calculator), httpUri)
' Create a binding that uses a username/password credential.
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = MessageCredentialType.UserName
' Add an endpoint.
sh.AddServiceEndpoint(GetType(ICalculator), b, "UserNamePasswordCalculator")
' Get a reference to the UserNamePasswordServiceCredential object.
Dim unpCredential As UserNamePasswordServiceCredential = sh.Credentials.UserNameAuthentication
' Print out values.
Console.WriteLine("IncludeWindowsGroup: {0}", unpCredential.IncludeWindowsGroups)
Console.WriteLine("UserNamePasswordValidationMode: {0}", unpCredential.UserNamePasswordValidationMode)
Console.WriteLine("CachedLogonTokenLifetime.Minutes: {0}", unpCredential.CachedLogonTokenLifetime.Minutes)
Console.WriteLine("CacheLogonTokens: {0}", unpCredential.CacheLogonTokens)
Console.WriteLine("MaxCachedLogonTokens: {0}", unpCredential.MaxCachedLogonTokens)
Console.ReadLine()
Remarques
Vous pouvez spécifier les paramètres d'authentification par nom d'utilisateur/mot de passe en appelant des membres de la classe UserNamePasswordServiceCredential sur cette instance, comme UserNamePasswordValidationMode et MembershipProvider.