Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 自动登录和注销FBA SharePoint网站_Asp.net_Sharepoint_Httpmodule - Fatal编程技术网

Asp.net 自动登录和注销FBA SharePoint网站

Asp.net 自动登录和注销FBA SharePoint网站,asp.net,sharepoint,httpmodule,Asp.net,Sharepoint,Httpmodule,我们有一个WSS3.0站点,它使用基于表单的身份验证(FBA)。我们想设置网站,以便某些用户可以自动登录,而不是获得登录屏幕,我不确定最好的方法来做到这一点 实际上,基于,我已经创建了一个HTTP模块来处理登录。更具体地说,我已经创建了一个备用登录页面,当点击该页面时,它将作为所需用户登录。但是,在我关闭浏览器后,它会让用户保持登录状态。也就是说,我启动浏览器,转到备用登录页面,触发HTTP模块代码并以所需用户身份登录,然后关闭浏览器。然后,当我尝试转到该站点时,该站点的标准登录页被跳过,因为我

我们有一个WSS3.0站点,它使用基于表单的身份验证(FBA)。我们想设置网站,以便某些用户可以自动登录,而不是获得登录屏幕,我不确定最好的方法来做到这一点

实际上,基于,我已经创建了一个HTTP模块来处理登录。更具体地说,我已经创建了一个备用登录页面,当点击该页面时,它将作为所需用户登录。但是,在我关闭浏览器后,它会让用户保持登录状态。也就是说,我启动浏览器,转到备用登录页面,触发HTTP模块代码并以所需用户身份登录,然后关闭浏览器。然后,当我尝试转到该站点时,该站点的标准登录页被跳过,因为我仍然以以前的用户身份登录该站点


我想我的问题可以归结为如何确保注销?有没有一种方法可以通过HTTP模块/处理程序实现这一点,或者我想在global.asax中做些什么?

愚蠢的我。我已将FormsAuthentication.RedirectFromLoginPage命令的cookie参数设置为True。这意味着身份验证cookie将持续50年。我想要的是在浏览器关闭时让cookie消失。如果cookie参数设置为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

如何确定何时点击该页面而不是标准登录页面?我们计划告诉大家该页面的URL是备用登录页面。那些“知道”的人会知道还有其他方法可以进入页面。我想我们也可以修改SharePoint web.config,将备用页面用于登录页面。