양식 인증을 사용하는 ASP.NET 웹 사이트를 실행합니다. 사실, 사용자는 아무 것도 입력 할 필요가 없었습니다. - 나는 Request.ServerVariables["LOGON_USER"]
을 가져 와서 사용자 정의 클래스 EmployeeInfo
을 사용하여 특정 SQL 데이터베이스에서이 사용자 이름을 조회 한 다음 결과에 따라 사용자가 기본 페이지로 리디렉션되었거나 다른 메시지를 표시하는 오류 페이지로 변경되었습니다Windows 인증 사용자 지정 유효성 검사 (데이터베이스에서)
의 Web.config :
<authentication mode="Forms">
<forms loginUrl="Login.aspx"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
Login.aspx : 오류의 유형에
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
FormsAuthentication.SignOut();
string UserName = Request.ServerVariables["LOGON_USER"];
EmployeeInfo CurrentEmployee = EmployeeInfo.RequestDBInfo(UserName); // SQL magic here
if (CurrentEmployee = null)
Response.Redirect("AccessDenied.aspx?Message=NoInfo");
else
if (CurrentEmployee.Suspended = true)
Response.Redirect("AccessDenied.aspx?Message=Suspended");
if (CurrentEmployee.Expired = true)
Response.Redirect("AccessDenied.aspx?Message=Expired");
if (CurrentEmployee.Position = null)
Response.Redirect("AccessDenied.aspx?Message=NoPosition");
else
FormsAuthentication.RedirectFromLoginPage(CurrentUserName, true);
}
}
그것은 최근까지 괜찮 일하는
우리는 자체에 대한 Windows 인증으로 전환했다 근본적인 이유. 이제 잘못된 사용자의 경우 내 웹 사이트는 기본적으로 Login.aspx
페이지를 열어 사용자를 적절한 오류 페이지로 리디렉션합니다. 그러나 사용자는 양식 인증이 수행되지 않고 사용자가 Windows에서 성공적으로 인증되므로 URL을 입력하면 페이지를 열 수 있습니다.
그래서 내 질문은 :
Windows 인증의 상단에 데이터베이스에서 추가 검사를 구현하는 가장 좋은 방법은 무엇입니까? 내가 아는 한 에서 Application_AuthenticateRequest
을 변경해야합니까?