Beispiel #1
0
 public bool CreateUser(string sDomainUser, string sPassword, string sEmail, string sFullName, string sRoles, bool bIsAdmin, Credentials credentials)
 {
     if (sDomainUser != "")
     {
         Login(credentials);
         if (!Sitecore.Security.Accounts.User.Exists(sDomainUser))
         {
             System.Web.Security.Membership.CreateUser(sDomainUser, "dummy", sEmail);
             Sitecore.Security.Accounts.User newUser = Sitecore.Security.Accounts.User.FromName(sDomainUser, true);
             newUser.Profile.LegacyPassword  = sPassword;
             newUser.Profile.FullName        = sFullName;
             newUser.Profile.IsAdministrator = bIsAdmin;
             foreach (string sRole in sRoles.Split('|'))
             {
                 if (sRole != "")
                 {
                     CreateRole(sRole, credentials);
                     newUser.Roles.Add(Sitecore.Security.Accounts.Role.FromName(sRole));
                 }
             }
             newUser.Profile.Save();
         }
     }
     return(true);
 }
Beispiel #2
0
        private SitecoreUserItem BuildSitecoreUserDataItem(Sitecore.Security.Accounts.User user)
        {
            var roleList = new List <string>();

            user.Roles.ToList().ForEach(r => roleList.Add(r.DisplayName));
            return(new SitecoreUserItem()
            {
                UserName = user.LocalName,
                FullUserName = user.Name,
                Domain = user.Domain.Name,
                FullName = user.Profile.FullName,
                Email = user.Profile.Email,
                Roles = string.Join(",", roleList.ToArray()),
                Comment = user.Profile.Comment
            });
        }