I need to initialize my membership provider, thus I start from calling it like this:
Public Overrides Sub Initialize(name As String, config As NameValueCollection)
Dim myNewAsp As New AspNetSqlProvider
If config Is Nothing Then Throw New ArgumentNullException("config")
If name Is Nothing OrElse name.Length = 0 Then name =" AspNetSqlMembershipProvider"
If String.IsNullOrEmpty(config("description")) Then
config.Remove("description")
config.Add("system.web/Membership", name)
End If
MyBase.Initialize(name, config)
And I call it from my code behind:
Dim SC As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection
membershipProviderWareHouse.Initialize("AspNetSqlMembershipProvider", SC)
In my Web.Config file I have:
<membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="20">
<providers >
<clear/>
<add
name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="TMPApplicationServices"
enablePasswordReset="true"
passwordFormat="Hashed"
enablePasswordRetrieval="false"
requiresQuestionAndAnswer="false"
passwordStrengthRegularExpression="(?=^.{8,20}$)(?=.*\d)(?=.*[a-zA-Z])(?=.*[!@#$%^])(?!.*\s).*$"
requiresUniqueEmail="true"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
As a conclusion, what I want is to get the passwordFormat
which declared in my web.config
file.
I'm trying to get the passwordFormat
with the following command:
Dim myMemPass As New MembershipPasswordFormat
But what I get is the clear(0)
value and not the Hashed(1)
which is declared in my web.config.
I really don't know what I'm doing wrong (because it is obvious that something is wrong here).
May I have an assistance?
* ADDITIONAL INFORMATION*
Public membershipProviderWareHouse As New AspNetSqlMembershipProvider
That is for membershipProviderWareHouse
which I forgot it.
I have made another call for the initialization:
Dim membershipSection As Web.Configuration.MembershipSection = ConfigurationManager.GetSection("system.web/membership")
Dim sqlProviderName As String = "AspNetSqlMembershipProvider"
Dim providerConfig As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection
providerConfig.Add("AspNetSqlMembershipProvider", (DBNull.Value).ToString)
membershipProviderWareHouse.Initialize(sqlProviderName, providerConfig)
Which doesn't seams to work either.