다음을 통해 공유


ServiceCredentials.UserNameAuthentication 속성

정의

이 서비스에 대한 현재 사용자 이름/암호 인증 설정을 가져옵니다.

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

속성 값

UserNamePasswordServiceCredential

UserNamePasswordServiceCredential 인스턴스입니다.

예제

다음 코드에서는 이 속성을 사용하여 서비스에 사용되는 자격 증명의 인스턴스를 가져오는 방법을 보여 줍니다.

// 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()

설명

이 인스턴스에서 UserNamePasswordServiceCredential 클래스의 멤버(예: UserNamePasswordValidationModeMembershipProvider)를 호출하여 사용자 이름/암호 인증 설정을 지정할 수 있습니다.

적용 대상