internal void ApplyConfiguration(UserNamePasswordServiceCredential userName)
 {
     if (userName == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("userName");
     }
     userName.UserNamePasswordValidationMode = this.UserNamePasswordValidationMode;
     userName.IncludeWindowsGroups           = this.IncludeWindowsGroups;
     userName.CacheLogonTokens         = this.CacheLogonTokens;
     userName.MaxCachedLogonTokens     = this.MaxCachedLogonTokens;
     userName.CachedLogonTokenLifetime = this.CachedLogonTokenLifetime;
     if (base.ElementInformation.Properties["membershipProviderName"].ValueOrigin != PropertyValueOrigin.Default)
     {
         userName.MembershipProvider = SystemWebHelper.GetMembershipProvider(this.MembershipProviderName);
         if (userName.MembershipProvider == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("InvalidMembershipProviderSpecifiedInConfig", new object[] { this.MembershipProviderName })));
         }
     }
     else if (userName.UserNamePasswordValidationMode == System.ServiceModel.Security.UserNamePasswordValidationMode.MembershipProvider)
     {
         userName.MembershipProvider = SystemWebHelper.GetMembershipProvider();
     }
     if (!string.IsNullOrEmpty(this.CustomUserNamePasswordValidatorType))
     {
         Type c = Type.GetType(this.CustomUserNamePasswordValidatorType, true);
         if (!typeof(UserNamePasswordValidator).IsAssignableFrom(c))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidUserNamePasswordValidatorType", new object[] { this.CustomUserNamePasswordValidatorType, typeof(UserNamePasswordValidator).ToString() })));
         }
         userName.CustomUserNamePasswordValidator = (UserNamePasswordValidator)Activator.CreateInstance(c);
     }
 }
Ejemplo n.º 2
0
 private UserNamePasswordValidator GetMembershipProviderValidator()
 {
     System.Web.Security.MembershipProvider membershipProvider;
     if (this.membershipProvider != null)
     {
         membershipProvider = (System.Web.Security.MembershipProvider) this.membershipProvider;
     }
     else
     {
         membershipProvider = SystemWebHelper.GetMembershipProvider();
     }
     if (membershipProvider == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MissingMembershipProvider")));
     }
     return(UserNamePasswordValidator.CreateMembershipProviderValidator(membershipProvider));
 }
        UserNamePasswordValidator GetMembershipProviderValidator()
        {
            MembershipProvider provider;

            if (this.membershipProvider != null)
            {
                provider = (MembershipProvider)this.membershipProvider;
            }
            else
            {
                provider = SystemWebHelper.GetMembershipProvider();
            }

            if (provider == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MissingMembershipProvider)));
            }
            return(UserNamePasswordValidator.CreateMembershipProviderValidator(provider));
        }