Пример #1
0
        public virtual IMemberAccountData GetMember()
        {
            String logMethodName = ".GetMember() - ";

            _log.Debug(logMethodName + " - Begin Method");

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                MembershipUser user = GetUser();
                if (user != null)
                {
                    MembershipUserWrapper wrappedMember = new MembershipUserWrapper(GetUser());
                    _log.Debug(logMethodName + " - End Method");
                    return(wrappedMember);
                }
            }
            _log.Debug(logMethodName + " - End Method");

            return(null);
        }
Пример #2
0
        public virtual IMemberAccountData CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status)
        {
            String logMethodName = ".CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) - ";

            _log.Debug(logMethodName + " - Begin Method");

            status = MemberCreationStatus.Error;

            IMemberAccountData data = null;

            MembershipCreateStatus createStatus = MembershipCreateStatus.Success;

            try
            {
                // Membership.CreateUser Method - throws exception MembershipCreateUserException if user is
                // not created:
                //     http://msdn.microsoft.com/en-us/library/t8yy6w3h.aspx
                data = new MembershipUserWrapper(Membership.CreateUser(
                                                     authInfo.Username,
                                                     authInfo.Password,
                                                     authInfo.Email));
            }

            catch (MembershipCreateUserException e)
            {
                createStatus = e.StatusCode;
                _log.Debug(logMethodName + " - User " + authInfo.Username + " was not created - status=" + createStatus);
            }

            catch (Exception ex)
            {
                SaltADMembershipProvider.ADConnector.LogActiveDirectoryMembershipProviderProperties();

                throw new SecurityAdapterException("An error has occured in the .NET Membership provider while calling Membership.CreateUser(username, password, username) for username " + authInfo.Username, ex);
            }

            switch (createStatus)
            {
            case MembershipCreateStatus.Success:
                status = MemberCreationStatus.Success;
                //FormsAuthentication.SetAuthCookie(authInfo.Username, true);
                //FormsAuthentication.Authenticate(authInfo.Username, authInfo.Password);
                break;

            case MembershipCreateStatus.DuplicateEmail:
                status = MemberCreationStatus.DuplicateEmail;
                break;

            case MembershipCreateStatus.DuplicateProviderUserKey:
                status = MemberCreationStatus.DuplicateUserName;
                break;

            case MembershipCreateStatus.DuplicateUserName:
                status = MemberCreationStatus.DuplicateUserName;
                break;

            case MembershipCreateStatus.InvalidAnswer:
                status = MemberCreationStatus.InvalidAnswer;
                break;

            case MembershipCreateStatus.InvalidEmail:
                status = MemberCreationStatus.InvalidEmail;
                break;

            case MembershipCreateStatus.InvalidPassword:
                status = MemberCreationStatus.InvalidPassword;
                break;

            case MembershipCreateStatus.InvalidProviderUserKey:
                status = MemberCreationStatus.InvalidUserName;
                break;

            case MembershipCreateStatus.InvalidQuestion:
                status = MemberCreationStatus.InvalidQuestion;
                break;

            case MembershipCreateStatus.InvalidUserName:
                status = MemberCreationStatus.InvalidUserName;
                break;

            case MembershipCreateStatus.ProviderError:
                status = MemberCreationStatus.AdapterError;
                break;

            case MembershipCreateStatus.UserRejected:
                status = MemberCreationStatus.UserRejected;
                break;

            default:
                status = MemberCreationStatus.Error;

                break;
            }

            _log.Debug(logMethodName + " - End Method");

            return(data);
        }