public static bool UpdateMember(UmbracoMemberProfile member)
        {
            try
            {
                IEnumerable <IMember> members = FindMemberByGuid(member.Properties.Where(x => x.Key == GUID).Select(x => x.Value).FirstOrDefault());
                if (members != null)
                {
                    foreach (IMember m in members)
                    {
                        m.Name  = member.UserProfile.DisplayName;
                        m.Email = member.UserProfile.EmailAddress;
                        ApplicationContext.Current.Services.MemberService.Save(m);
                        AssignRole(m, member.Roles);
                        LogHelper.Info <MemberHelper>(string.Format("{0}(name) updated, {1}(id)", m.Name, m.Id));
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                LogHelper.Error <MemberHelper>("UpdateMember exception: ", ex);
                return(false);
            }
        }
        public static int CreateMember(UmbracoMemberProfile member, string domain)
        {
            string usernameWithDomain = string.Empty;

            if (!string.IsNullOrEmpty(domain))
            {
                usernameWithDomain = string.Format("{0}\\{1}", domain, member.UserProfile.LoginName);
            }
            else
            {
                usernameWithDomain = member.UserProfile.LoginNameWithDomain;
            }

            return(CreateMember(usernameWithDomain, member.UserProfile.DisplayName, member.UserProfile.EmailAddress, null, member.Roles, member.Properties));
        }
        public static bool ImportADAccount(ref int importedCount, ref int updatedCount, ref int failCount, string domain = null, List <string> groups = null, List <UserProfile> users = null)
        {
            bool result = false;

            if (users != null)
            {
                foreach (UserProfile user in users)
                {
                    List <KeyValuePair <string, string> > properties = new List <KeyValuePair <string, string> >();
                    properties.Add(new KeyValuePair <string, string>("guid", user.GUID.ToString()));
                    properties.Add(new KeyValuePair <string, string>("distinguishedName", user.DistinguishedName));
                    UmbracoMemberProfile member = new UmbracoMemberProfile(user, properties, groups);

                    if (MemberHelper.FindMemberByGuid(user.GUID.ToString()).Count() == 0)
                    {
                        if (MemberHelper.CreateMember(member, domain) != -1)
                        {
                            importedCount++;
                        }
                        else
                        {
                            failCount++;
                        }
                    }
                    else
                    {
                        if (MemberHelper.UpdateMember(member))
                        {
                            updatedCount++;
                        }
                        else
                        {
                            failCount++;
                        }
                    }
                }
                result = true;
            }
            return(result);
        }
 public static int CreateMember(UmbracoMemberProfile member)
 {
     return(CreateMember(member, null));
 }