DefaultAuthenticationEventHandler 대리자

정의

DefaultAuthenticationModuleDefaultAuthentication_OnAuthenticate 이벤트를 처리하는 메서드를 나타냅니다.

public delegate void DefaultAuthenticationEventHandler(System::Object ^ sender, DefaultAuthenticationEventArgs ^ e);
public delegate void DefaultAuthenticationEventHandler(object sender, DefaultAuthenticationEventArgs e);
type DefaultAuthenticationEventHandler = delegate of obj * DefaultAuthenticationEventArgs -> unit
Public Delegate Sub DefaultAuthenticationEventHandler(sender As Object, e As DefaultAuthenticationEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
DefaultAuthenticationEventArgs

이벤트 데이터를 포함하는 DefaultAuthenticationEventArgs입니다.

예제

다음 코드 예제에서는 합니다 DefaultAuthentication_OnAuthenticate 테스트할 이벤트 여부를 User 속성이 현재 HttpContextnull합니다. 속성이 null, 샘플 집합을 User 속성이 현재 HttpContextGenericPrincipal 개체 위치를 IdentityGenericPrincipal 개체가 GenericIdentity 사용 하 여를 Name "기본 값을 ".

참고

합니다 DefaultAuthentication_OnAuthenticate 이벤트가 발생 하기 전에 AuthorizeRequest 이벤트입니다. 결과적으로 설정한 경우에 User 속성이 현재 HttpContext 을 사용자 지정 id에 영향을 주므로 애플리케이션의 동작입니다. 예를 들어 클래스를 FormsAuthentication 사용 중이고 인증된 사용자만 사이트에 액세스할 수 있도록 하는 경우 섹션을 사용하고 authorization 를 지정하면 <deny users="?" />이 샘플 deny 에서는 사용자가 이름이 "기본값"인 이름을 가지기 때문에 요소가 무시됩니다. 대신 지정 하는 경우 <deny users="default" /> 인증 된 사용자만 사이트를 액세스할 수 있도록 합니다.

public void DefaultAuthentication_OnAuthenticate(object sender,
                                                 DefaultAuthenticationEventArgs args)
{
  if (args.Context.User == null)
    args.Context.User = 
      new System.Security.Principal.GenericPrincipal(
        new System.Security.Principal.GenericIdentity("default"),
        new String[0]);
}
Public Sub DefaultAuthentication_OnAuthenticate(sender As Object, _
                                                args As DefaultAuthenticationEventArgs)
  If args.Context.User Is Nothing Then
    args.Context.User = _
      new System.Security.Principal.GenericPrincipal( _
        new System.Security.Principal.GenericIdentity("default"), _
        new String(0) {})
  End If
End Sub

설명

DefaultAuthenticationEventHandler 대리자에 대해 정의 된 합니다 Authenticate 이벤트는 DefaultAuthenticationModule 클래스. 액세스할 수 있습니다 합니다 Authenticate 의 이벤트를 DefaultAuthenticationModule 라는 서브루틴을 지정 하 여 클래스 DefaultAuthentication_OnAuthenticate ASP.NET 애플리케이션의 Global.asax 파일에. Authenticate 이벤트가 발생 한 후를 AuthenticateRequest 이벤트 있는지 확인 하는 데 사용 되는 User 속성이 현재 HttpContext 채워집니다는 IPrincipal 개체.

사용할 수는 Context 의 속성을 DefaultAuthenticationEventArgs 개체가 제공를 DefaultAuthentication_OnAuthenticate 이벤트가 설정를 User 속성이 현재 HttpContext 사용자지정IPrincipal개체입니다. 에 대 한 값을 지정 하지 않으면를 User 의 속성을 HttpContext 중에 제공를 DefaultAuthentication_OnAuthenticate 이벤트를 DefaultAuthenticationModule 설정를 User 속성을 HttpContextGenericPrincipal 어떠한 사용자 정보도 포함 하는 개체입니다.

DefaultAuthentication_OnAuthenticate 이벤트 후에 발생 합니다 AuthenticateRequest 이벤트 전과 AuthorizeRequest 이벤트. 애플리케이션에 대한 액세스를 거부하거나 허용할 사용자 이름에 의존하는 섹션이 있는 경우 authorization 현재 HttpContext 속성을 수정하면 User 애플리케이션의 동작에 영향을 줄 수 있습니다. 구성에서 섹션을 지정할 authorization 때 DefaultAuthentication_OnAuthenticate 이벤트 중에 설정한 사용자 이름을 고려해야 합니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상