将SitecoreUser.Profile与表单身份验证一起使用

将SitecoreUser.Profile与表单身份验证一起使用,sitecore,sitecore8,Sitecore,Sitecore8,我们使用sitecore管理注册用户(extranet域),在创建新的虚拟用户时,我们使用Profile.email属性向其发送电子邮件,然后调用Profile.Save()方法。 其他地方的另一个属性读取userProfile.Email,一开始一切正常。 此外,我们还使用表单身份验证和“记住我”功能。 问题是,当我们关闭浏览器并重新打开它时,Sitecore.Context.User包含有关单击“记住我”的实际用户的信息,但User.Profile的电子邮件始终为空。 我尝试了Reload(

我们使用sitecore管理注册用户(extranet域),在创建新的虚拟用户时,我们使用
Profile.email
属性向其发送电子邮件,然后调用
Profile.Save()
方法。 其他地方的另一个属性读取
userProfile.Email
,一开始一切正常。 此外,我们还使用表单身份验证和“记住我”功能。 问题是,当我们关闭浏览器并重新打开它时,
Sitecore.Context.User
包含有关单击“记住我”的实际用户的信息,但
User.Profile
的电子邮件始终为空。 我尝试了
Reload()
initialize()
它们不起作用。我还尝试通过用户名(
user.FromName()
)再次获取用户,但返回的用户对象也没有配置文件电子邮件


哪里做错了?

这本书中有一条非常重要的评论。它与Sitecore 6相关,但据我所知,它应该与Sitecore 8配合使用,因为安全模型中没有重大更改。它为我工作

重要信息只有在为虚拟用户分配角色和配置文件属性后,才能登录虚拟用户。登录后分配的角色和配置文件属性将在后续请求时丢失


非常感谢您的回答,但是在填写Profile.Email并保存之后,在后续请求中(我们使用success=AuthenticationManager.Login(sitecoreVirtualUser.Name,persist))配置文件数据不会丢失。仅当Sitecore和ASP.NET身份验证尝试从ASPXAUTH cookie创建新会话时,在关闭浏览器后启动新会话后,数据才会丢失。但是电子邮件没有被填满。我希望这是清楚的,我不这么认为。我不是最初实施这个的人。如何确定?打开showconfig.aspx并在switchingProviders下查找switchingProviders部分有一个仅包含以下内容的标记:
Sitecore.Security.Accounts.User user =
Sitecore.Security.Authentication.AuthenticationManager.BuildVirtualUser(@"domain\user"
, true);
if (user != null)
{
 string domainRole = @"domain\role";
 if (Sitecore.Security.Accounts.Role.Exists(domainRole))
 {
 user.Roles.Add(Role.FromName(domainRole));
 }

 user.Profile.Email = "user@domain.com";
 user.Profile[“Custom Property”] = “Custom Value”;
 user.Profile.Save();
 Sitecore.Security.Authentication.AuthenticationManager.LoginVirtualUser(user);
}