在DotnetNuke(DNN)中设置密码问题

在DotnetNuke(DNN)中设置密码问题,dotnetnuke,Dotnetnuke,我需要存储安全问题和答案,它们是aspnet\u成员资格表passwordQuestion和PasswordAnswer中的列 UserInfo User = new UserInfo(); User.AffiliateID = Null.NullInteger; User.DisplayName =txtDisplayName.Text; User.FirstName = txtFirstName.Text; Us

我需要存储安全问题和答案,它们是aspnet\u成员资格表passwordQuestion和PasswordAnswer中的列

        UserInfo User = new UserInfo();
        User.AffiliateID = Null.NullInteger;
        User.DisplayName =txtDisplayName.Text;
        User.FirstName = txtFirstName.Text;
        User.LastName = TxtLastName.Text;
        User.Membership.Username = txtUserName.Text;
        User.Membership.Password = txtPassword.Text;
        User.Membership.CreatedDate = DateTime.Now;
        User.Membership.Email = txtEmail.Text;
        User.PortalID = this.PortalId;
        User.Username = txtUserName.Text;
        User.Email = txtEmail.Text;
        User.Membership.PasswordQuestion =TxtSecurityQuestion.Text;
        User.Membership.PasswordAnswer = TxtSecurityAnswer.Text;
        UserCreateStatus ucStatus = UserController.CreateUser(ref User);

我无法将密码问题和答案存储在aspnet_成员资格表中

您需要创建成员资格对象并将其附加到新用户

Dim newMemebership As New UserMembership(User)
With newMemebership
    .CreatedDate = Date.Now()
    .Password = txtPassword.Text
    .PasswordAnswer = Answer
    .PasswordQuestion =  Question
     .etc....
End With
user.membership = newmembership

抱歉,它是VB,但我确信您可以将其切换到

如果您在SQL成员资格提供程序中将requiresQuestionAndAnswer属性设置为true,DNN将自动为这些字段提供UI并填充它们

<membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="15">
  <providers>
    <clear />
    <!-- Configuration for AspNetSqlMembershipProvider:
            connectionStringName="string"               Name corresponding to the entry in <connectionStrings> section where the connection string for the provider is specified
            maxInvalidPasswordAttempts="int"            The number of failed password attempts, or failed password answer attempts that are allowed before locking out a user?s account
            passwordAttemptWindow="int"                 The time window, in minutes, during which failed password attempts and failed password answer attempts are tracked
            enablePasswordRetrieval="[true|false]"      Should the provider support password retrievals
            enablePasswordReset="[true|false]"          Should the provider support password resets
            requiresQuestionAndAnswer="[true|false]"    Should the provider require Q & A
            minRequiredPasswordLength="int"             The minimum password length
            minRequiredNonalphanumericCharacters="int"  The minimum number of non-alphanumeric characters
            applicationName="string"                    Optional string to identity the application: defaults to Application Metabase path
            requiresUniqueEmail="[true|false]"          Should the provider require a unique email to be specified
            passwordFormat="[Clear|Hashed|Encrypted]"   Storage format for the password: Hashed (SHA1), Clear or Encrypted (Triple-DES)
            description="string"                        Description of what the provider does
            -->
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SiteSqlServer" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="true" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="false" passwordFormat="Encrypted" applicationName="DotNetNuke" description="Stores and retrieves membership data from the local Microsoft SQL Server database" />
  </providers>
</membership>