2010-12-15 74 views
1

我必须存储安全问题和答案的要求,他们都列aspnet_Membership表passwordQuestion和PasswordAnswer.i现在用的是下面的代码在DotNetNuke的设置PasswordQuestion(DNN)

 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_Membership表

回答

0

你需要创建一个成员对象,并将其附加到新的用户

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

对不起,但我确定你可以切换它

3

如果在SQL成员资格提供程序中设置requiresQuestionAndAnswer属性为true,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> 
相关问题