티스토리 뷰

정보 보관 ver1.0

ASP.NET Login 컨트롤 개요

James Wetzel 2011. 6. 22. 16:16


ASP.NET Login 컨트롤 개요
 : http://msdn.microsoft.com/ko-kr/library/ms178329.aspx


로그인 컨트롤
ChangePassword
CreateUserWizard
Login
LoginName
LoginStatus
LoginView
PasswordRecovery등 모든 로그인 컨트롤의 상태는 FormsAuthentication.SetAuthCookie("", false) 메소드에 의해 결정된다

FormsAuthentication 클래스는?
  웹 응용 프로그램의 폼 인증 서비스를 관리합니다.


<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
{
    // Insert code that implements a site-specific custom
    // authentication method here.
    //
    // This example implementation always returns false.
          return false;
}

private void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    bool Authenticated = false;
    Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);

     // 인증이 성공한 경우
    //사용자 지정 인증 체계에서는 사용자가 인증되었음을 나타내도록 Authenticated 속성을 true로 설정해야 합니다.   
    e.Authenticated = Authenticated;
   
    //인증이 성공한 경우
    FormsAuthentication.SetAuthCookie(Login1.UserName, false);
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server"
                OnAuthenticate="OnAuthenticate">
            </asp:Login>
        </form>
    </body>
</html>

비고]
인증에 성공한 사용자의 이름을 호출하고 싶은 경우
Response.Write(this.User.Identity.Name);

참조 : http://msdn.microsoft.com/ko-kr/library/system.web.ui.page.user.aspx

728x90
반응형