Пример #1
0
        public override IMemberAccountData CreateMember(MemberAuthInfo authInfo, out MemberCreationStatus status)
        {
            String logMethodName = ".CreateMember(MemberAuthInfo authInfo, out MemberCreationStatus status) - ";

            _log.Debug(logMethodName + "Begin Method");
            MemberAccountData accountData = (MemberAccountData)base.CreateMember(authInfo, out status);

            SetAccountDataFromAD(ref accountData);
            RecreateIndividualIdCookie(accountData.MemberId.ToString());

            _log.Debug(logMethodName + "End Method");
            return(accountData);
        }
Пример #2
0
        public virtual IMemberAccountData CreateMember(MemberAuthInfo authInfo, out MemberCreationStatus status)
        {
            String logMethodName = ".CreateMember(MemberAuthInfo authInfo, out MemberCreationStatus status) - ";

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


            IMemberAccountData returnData;

            returnData = CreateMember(
                authInfo,
                new MemberProfileData()
            {
                EmailAddress = authInfo.Email
            },
                out status);

            _log.Debug(logMethodName + " - End Method");
            return(returnData);
        }
Пример #3
0
        public SiteMember CreateMember(MemberAuthInfo authInfo, MemberProfileData profile, out MemberCreationStatus status, IList <IContextActionValidationRequest <IContextActionValidator> > validationRequests = null)
        {
            const string logMethodName = ".CreateMember(MemberAuthInfo, MemberProfileData, out MemberCreationStatus, IList<IContextActionValidationRequest<IContextActionValidator>>)";
            const string logEndMessage = logMethodName + " - End Method";

            _log.Info(logMethodName + " - Creating new SiteMember");
            _log.Debug(logMethodName + " - Begin Method");
            SiteMember newMember = null;

            status = MemberCreationStatus.Error;

            IMemberAccountData accountData = null;
            int timesToTry = 2;

            //SWD-7461 - adding retry logic.
            for (int i = 0; i < timesToTry; i++)
            {
                try
                {
                    _log.Debug(logMethodName + " - Calling ISecurityAdapter.CreateMember(MemberAuthInfo authInfo, MemberProfileData data, out MemberCreationStatus status)");
                    status      = MemberCreationStatus.Error;
                    accountData = _adapter.CreateMember(authInfo, profile, out status);
                    break;
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + " - Error Creating new member account using the ISecurityAdapter.CreateMember will retry again", ex);
                    System.Threading.Thread.Sleep(1000);
                    accountData = null;
                }
            }

            if (status == MemberCreationStatus.Success)
            {
                _log.Info(logMethodName + " - MemberAccount created successfully by ISecurityAdapter.CreateMember - Creating MemberProfile");

                var memberProfile = new MemberProfileData(profile)
                {
                    MemberId       = accountData.MemberId,
                    LastModified   = DateTime.Now,
                    LastModifiedBy = accountData.MemberId
                };
                if (memberProfile.ProviderKeys == null)
                {
                    memberProfile.ProviderKeys = new Dictionary <string, object>();
                }
                memberProfile.ProviderKeys.Add("ActiveDirectoryKey", accountData.MemberId); // We prob dont need this, code using the ADKey lower in the framework will be ignored

                try
                {
                    IMemberProfileData data;
                    _log.Debug(logMethodName + " - Calling IContextDataProvider.CreateMemberProfile(MemberProfileData data, ProviderKeys keys)");
                    //TODO verify and remove provider key integration at this layer. - May need pin based lookup for pre-registered accounts to call update.
                    data          = _provider.CreateMemberProfile(memberProfile, memberProfile.ProviderKeys);
                    memberProfile = new MemberProfileData(data);
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + " - Error Creating new member profile using the IContextDataProvider - Rolling back new account", ex);
                    _log.Info(logMethodName + " - Rolling back - STEP 1. DELETE MEMBER ACCOUNT");
                    _log.Debug(logMethodName + " - Calling ISecurityAdapter.DeleteMember(Object memberId)");

                    _adapter.DeleteMember(accountData.Username);
                    status = MemberCreationStatus.AdapterError;

                    _log.Debug(logEndMessage);
                    accountData = null;
                }

                try
                {
                    newMember = new SiteMember(accountData, memberProfile);
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + " - Error Creating new sitemember instance", ex);
                    _log.Debug(logEndMessage);
                    newMember = null;
                }
            }
            else
            {
                // SWD-5616
                _log.Warn(logMethodName + " - Member Creation Unsuccessful.  Status: " + status);
            }

            _log.Debug(logEndMessage);
            return(newMember);
        }
Пример #4
0
        public override IMemberAccountData CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status)
        {
            String logMethodName = ".CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status) - ";

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

            MemberAccountData accountData = (MemberAccountData)base.CreateMember(authInfo, profile, out status);

            _log.Debug("Create Member Status: " + status.ToString());
            //PROBLEM?:  Here we still try to set account data even if there was a problem successfully creating the member.
            SetAccountDataFromAD(ref accountData);
            RecreateIndividualIdCookie(accountData.MemberId.ToString());

            _log.Debug(logMethodName + "End Method");
            return(accountData);
        }
Пример #5
0
 public SiteMember CreateMember(MemberAuthInfo authInfo, MemberProfileData profile, out MemberCreationStatus status, System.Collections.Generic.IList <IContextActionValidationRequest <IContextActionValidator> > validationRequests = null)
 {
     status = MemberCreationStatusResponse;
     return(CreateMemberResponse);
 }
Пример #6
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);
        }
Пример #7
0
 public IMemberAccountData CreateMember(MemberAuthInfo authInfo, IMemberProfileData profile, out MemberCreationStatus status)
 {
     status = MemberCreationStatusResponse;
     return(CreateMemberResponse);
 }
Пример #8
0
 //Member Security
 public IMemberAccountData CreateMember(MemberAuthInfo authInfo, out MemberCreationStatus status)
 {
     throw new NotImplementedException();
 }