SiteCore - Security相关

修改User:

if (User.Identity.IsAuthenticated)
{
    using (new SecurityDisabler())
    {
    // current user must be authenticated, othrewise will throw error "can't ....to aynonmous user",
    // if knows user name, can use User.FromName(username, authenticated) to authenticate usre for editing
var profile = Sitecore.Context.User.Profile; profile.FullName = accountFirstName + " " + accountLastName; profile.Save(); } }

重置密码:

using System.Web.Security;

MembershipUser user = Membership.GetUser(sitecoreUser.Name);
string newPassword = user.ResetPassword();

// create new password
string pwd = Membership.GeneratePassword(length, nonAlphaNum);

创建User:

using Sitecore.Security.Accounts;

User newUser = Sitecore.Security.Accounts.User.Create(username, password);

获得Domain下的Users:

var users = Sitecore.Security.Domains.Domain.GetUsers();

Login:

using Sitecore.Security.Authentication;
bool loginResult = AuthenticationManager.Login(user.Name, password)
posted @ 2012-05-29 13:39  peng.qd  阅读(248)  评论(0)    收藏  举报