public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException("username");
            }
            string tenantName;
            string tenantUsername;

            if (!Upn.TryParse(username, out tenantName, out tenantUsername))
            {
                return(false);  //invalid username format
            }
            try
            {
                if (!AuthenticationProxy.UserExists(tenantName, tenantUsername))
                {
                    return(false); //not exists
                }
                AuthenticationProxy.DeleteUser(tenantName, tenantUsername);
            }
            catch (Exception ex)
            {
                throw new ProviderException(ex.Message, ex);
            }
            return(true);
        }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            status = MembershipCreateStatus.Success;
            string tenantName;
            string tenantUsername;

            if (string.IsNullOrEmpty(username))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return(null);
            }

            if (!Upn.TryParse(username, out tenantName, out tenantUsername))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return(null);
            }

            if (string.IsNullOrEmpty(email))
            {
                status = MembershipCreateStatus.InvalidEmail;
                return(null);
            }

            if (string.IsNullOrEmpty(password) || password.Length < MinRequiredPasswordLength)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            int i = 0;

            for (int j = 0; j < password.Length; j++)
            {
                if (!char.IsLetterOrDigit(password, j))
                {
                    i++;
                }
            }
            if (i < MinRequiredNonAlphanumericCharacters)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }
            if ((PasswordStrengthRegularExpression.Length > 0) && !Regex.IsMatch(password, PasswordStrengthRegularExpression))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }
            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true);

            base.OnValidatingPassword(args);
            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            try
            {
                if (AuthenticationProxy.UserExists(tenantName, tenantUsername))
                {
                    status = MembershipCreateStatus.DuplicateUserName;
                    return(null);
                }
                AuthenticationProxy.CreateUser(tenantName, tenantUsername, password, email);
            }
            catch (Exception ex)
            {
                throw new ProviderException(ex.Message, ex);
            }
            return(GetUser(username, false));
        }