使用SessionSecurityToken在Sharepoint 2010中永久登录?

使用SessionSecurityToken在Sharepoint 2010中永久登录?,sharepoint,sharepoint-2010,identity,claims-based-identity,Sharepoint,Sharepoint 2010,Identity,Claims Based Identity,我有一个在Sharepoint上运行的公共网站。现在,当用户登录时,我们希望他们能够选择“记住登录”,这样他们就可以持久登录 据我所知,Sharepoint支持这一点。您唯一需要做的就是运行: spFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(someSessionSecurityToken,true) 现在,我不知道如何获取重载所需的SessionSecurityToken。目前我们使用的是不带true的 我们的

我有一个在Sharepoint上运行的公共网站。现在,当用户登录时,我们希望他们能够选择“记住登录”,这样他们就可以持久登录

据我所知,Sharepoint支持这一点。您唯一需要做的就是运行:

spFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(someSessionSecurityToken,true)

现在,我不知道如何获取重载所需的SessionSecurityToken。目前我们使用的是不带true的

我们的守则:

MembershipProvider membershipProvider = Membership.Providers["CustomProvider"];

            VerifyCredentialsResult verifyCredentialsDto = null;

            using (WindowsIdentity.Impersonate(IntPtr.Zero))
            {
                var customerService = Kernel.Resolve<ICustomerServiceAgent>();
                verifyCredentialsDto = customerService.VerifyCredentials(userName, passwordOrSsoToken);
                Kernel.ReleaseComponent(customerService);
            }

            if (!verifyCredentialsDto.Succes)
                return false;

            SecurityToken securityToken =
                SPSecurityContext.SecurityTokenForFormsAuthentication(new Uri(SPContext.Current.Web.Url),
                                                                      "CustomProvider",
                                                                      "CustomRoleProvider",
                                                                      verifyCredentialsDto.CustomerId,
                                                                      passwordOrSsoToken);
            if (securityToken != null)
            {
                SPFederationAuthenticationModule spFederationAuthenticationModule =
                    SPFederationAuthenticationModule.Current;

                spFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(securityToken);
                return true;
            }
            return false;
MembershipProvider MembershipProvider=Membership.Providers[“CustomProvider”];
VerifyCredentialsResult verifyCredentialsDto=null;
使用(WindowsIdentity.Impersonate(IntPtr.Zero))
{
var customerService=Kernel.Resolve();
verifyCredentialsDto=customerService.VerifyCredentials(用户名、密码或密码);
ReleaseComponent(customerService);
}
如果(!verifyCredentialsDto.成功)
返回false;
SecurityToken SecurityToken=
SPSecurityContext.SecurityTokenForFormsAuthentication(新Uri(SPContext.Current.Web.Url),
“CustomProvider”,
“CustomRoleProvider”,
向客户ID验证证书,
密码(SOTOKEN);
if(securityToken!=null)
{
SPFederationAuthenticationModule SPFederationAuthenticationModule=
SPFederationAuthenticationModule.Current;
spFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(securityToken);
返回true;
}
返回false;
实现持久性true/false参数很容易,但是在登录时如何更改代码以支持持久性cookie呢