Установить PasswordQuestion в DotnetNuke (DNN) - PullRequest
1 голос
/ 15 декабря 2010

У меня есть требование для хранения секретных вопросов и ответов. Это столбцы aspnet_Membership Таблица passwordQuestion и PasswordAnswer.i я использую следующий код

        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);

Я не могуstore Password Вопрос и ответ в таблице aspnet_Membership

Ответы [ 2 ]

3 голосов
/ 15 декабря 2010

Если вы установите для атрибута requireQuestionAndAnswer значение true в поставщике членства SQL, DNN автоматически предоставит интерфейс и заполнит эти поля.

<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>
0 голосов
/ 15 декабря 2010

Вам необходимо создать объект членства и прикрепить его к новому пользователю

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

Извините, но я уверен, что вы можете переключить его

...