2009-06-26 7 views
1

FBA (폼 기반 인증)를 사용하는 WSS 3.0 사이트가 있습니다. 특정 사용자가 로그인 화면을 가져 오는 대신 자동으로 로그인 할 수 있도록 사이트를 설정하고 싶습니다.이 작업을 수행하는 가장 좋은 방법은 확실하지 않습니다.FBA SharePoint 사이트에 자동으로 로그인 및 로그 아웃

사실, this article을 기반으로 로그인을 처리하는 HTTP 모듈을 이미 만들었습니다. 특히, 대체 로그인 페이지를 만들었고 해당 페이지가 눌려지면 원하는 사용자로 로그인합니다. 하지만 브라우저를 닫은 후에도 사용자가 로그인 상태를 유지합니다. 즉, 브라우저를 시작하고 대체 로그인 페이지로 이동 한 후 HTTP 모듈 코드가 실행되고 원하는 사용자로 로그인 한 다음 브라우저를 닫습니다. 그런 다음 사이트로 이동하려고하면 이전 사용자로 사이트에 계속 로그인했기 때문에 사이트의 표준 로그인 페이지는 건너 뜁니다.

제 질문은 로그 오프 할 수있는 방법을 알려줍니다. HTTP 모듈/처리기로이 작업을 수행 할 수있는 방법이 있습니까? 아니면 global.asax에서 작업을 수행하고 싶습니까?

+0

표준 로그인 페이지 대신 해당 페이지를 때리는 방법을 어떻게 결정합니까? – Rob

+0

우리는 페이지의 URL을 대체 로그인 페이지라고 말하는 사람들을 계획하고 있습니다. "알고있는"사람들은 페이지에 접근하는 다른 방법이 있다는 것을 알게 될 것입니다. 로그인 페이지의 대체 페이지를 사용하도록 SharePoint web.config를 수정할 수도 있습니다. – LunaCrescens

답변

0

어리석은 나를. 내 FormsAuthentication.RedirectFromLoginPage 명령의 쿠키 매개 변수를 True로 설정했습니다. 이는 인증 쿠키가 50 년간 지속될 것임을 의미합니다. 내가 원했던 것은 브라우저를 닫을 때 쿠키가 사라지게하는 것이 었습니다. 쿠키 매개 변수가 False로 설정되면 쉽게 완료됩니다. 다른 사람들이 관심이 있다면 내 코드는 ...

Imports System.Web 
Imports System.Web.Security 
Imports System.Collections.Specialized 
Imports System.Security.Principal 
Imports System.Threading 
Imports System.Web.UI 

Public Class AuthModule 
    Implements IHttpModule 

    Public Sub Dispose() Implements System.Web.IHttpModule.Dispose 
    End Sub 

    Public Sub Init(ByVal app As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init 
     AddHandler app.PreRequestHandlerExecute, New EventHandler(AddressOf OnPreRequestHandlerExecute) 
    End Sub 

    Public Sub OnPreRequestHandlerExecute(ByVal sender As Object, _ 
              ByVal e As EventArgs) 

     ' Check to see if the alternate page has been accessed 
     If HttpContext.Current.Request.Url.ToString.ToUpper.EndsWith("AUTOLOGIN.ASPX") Then 
      ' Alternate page has been accessed, so log in using predetermined account 

      ' Retrieve the user name and password 
      Dim userName As String = "user" 
      Dim userPassword As String = "password" 

      ' Build the user id 
      Dim roles As String() = Nothing 
      Dim webIdentity As New GenericIdentity(userName, "Form") 
      Dim principal As New GenericPrincipal(webIdentity, roles) 

      ' Specify the user 
      HttpContext.Current.User = principal 
      Thread.CurrentPrincipal = principal 

      ' Redirect from the login page to the start page 
' Note, this is the line I initially had incorrect. That is, I had the 
' second parameter set to True, which will persist the authentication cookie. 
' Setting the second parameter to False will cause the authentication cookie 
' to go away when the browser is closed. Yeah! 
      FormsAuthentication.RedirectFromLoginPage(HttpContext.Current.User.Identity.Name.ToString, False) 
     End If 

    End Sub 

End Class 
관련 문제