Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Getting attributs for membership provider from web.config

Reply
Thread Tools

Getting attributs for membership provider from web.config

 
 
news.microsoft.com
Guest
Posts: n/a
 
      10-12-2005
How can get the values of for example RequiresUniqueEmail from my own
membershipprovider? Using is
System.Web.Security.Membership.RequiresQuestionAnd Answer; is not an option
because it will call the property from the membership provider.

<membership userIsOnlineTimeWindow="15"
defaultProvider="MembershipProviderSample">
<providers>
<add name="MembershipProviderSample"
type="SecurityProviders.MembershipProviderSample" EnablePasswordReset="true"
EnablePasswordRetrieval="true" MaxInvalidPasswordAttempts="5"
MinRequiredNonAlphanumericCharacters="0"
MinRequiredPasswordLength="6"
MembershipPasswordFormat="Clear"
RequiresQuestionAndAnswer="true"
RequiresUniqueEmail="true"
PasswordStrengthRegularExpression="[0-9a-zA-Z]{6,12}$"/>
</providers>
</membership>


 
Reply With Quote
 
 
 
 
Dominick Baier [DevelopMentor]
Guest
Posts: n/a
 
      10-12-2005
Hello news.microsoft.com,

the source looks like this (in the Membership class)

public static bool RequiresQuestionAndAnswer
{
get
{
Membership.Initialize();
return Membership.Provider.RequiresQuestionAndAnswer;
}
}

Initialize loads the configured default provider and assigns the instance
to the Provider property. So - they read the value from the currently loaded
provider implementation - which is your custom provider. You are responsible
in your provider to implement a Initialize method and read the values from
the NameValueCollection (to populate the properties).

so - your scenario should work.

you have to closely follow all the design pattern by microsoft - read more
here:
http://msdn.microsoft.com/asp.net/be...s/default.aspx

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

> How can get the values of for example RequiresUniqueEmail from my own
> membershipprovider? Using is
> System.Web.Security.Membership.RequiresQuestionAnd Answer; is not an
> option because it will call the property from the membership provider.
>
> <membership userIsOnlineTimeWindow="15"
> defaultProvider="MembershipProviderSample">
> <providers>
> <add name="MembershipProviderSample"
> type="SecurityProviders.MembershipProviderSample"
> EnablePasswordReset="true"
> EnablePasswordRetrieval="true" MaxInvalidPasswordAttempts="5"
> MinRequiredNonAlphanumericCharacters="0"
> MinRequiredPasswordLength="6"
> MembershipPasswordFormat="Clear"
> RequiresQuestionAndAnswer="true"
> RequiresUniqueEmail="true"
> PasswordStrengthRegularExpression="[0-9a-zA-Z]{6,12}$"/>
> </providers>
> </membership>



 
Reply With Quote
 
 
 
 
Roel Veldhuizen
Guest
Posts: n/a
 
      10-12-2005
There is no Membership.Initialize(); atleast not in asp.net 2 but i found a
function Initialize in System.Web.Security.Membership.Provider. The
parameter string name is clear thats te provider name but the other
parameter is what i don't understand.
public virtual void Initialize (
string name,
NameValueCollection config
)"Dominick Baier [DevelopMentor]" <(E-Mail Removed)>
wrote in message news:(E-Mail Removed). com...
> Hello news.microsoft.com,
>
> the source looks like this (in the Membership class)
>
> public static bool RequiresQuestionAndAnswer
> {
> get
> {
> Membership.Initialize();
> return Membership.Provider.RequiresQuestionAndAnswer;
> }
> }
>
> Initialize loads the configured default provider and assigns the instance
> to the Provider property. So - they read the value from the currently
> loaded provider implementation - which is your custom provider. You are
> responsible in your provider to implement a Initialize method and read the
> values from the NameValueCollection (to populate the properties).
>
> so - your scenario should work.
>
> you have to closely follow all the design pattern by microsoft - read more
> here:
> http://msdn.microsoft.com/asp.net/be...s/default.aspx
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>> How can get the values of for example RequiresUniqueEmail from my own
>> membershipprovider? Using is
>> System.Web.Security.Membership.RequiresQuestionAnd Answer; is not an
>> option because it will call the property from the membership provider.
>>
>> <membership userIsOnlineTimeWindow="15"
>> defaultProvider="MembershipProviderSample">
>> <providers>
>> <add name="MembershipProviderSample"
>> type="SecurityProviders.MembershipProviderSample"
>> EnablePasswordReset="true"
>> EnablePasswordRetrieval="true" MaxInvalidPasswordAttempts="5"
>> MinRequiredNonAlphanumericCharacters="0"
>> MinRequiredPasswordLength="6"
>> MembershipPasswordFormat="Clear"
>> RequiresQuestionAndAnswer="true"
>> RequiresUniqueEmail="true"
>> PasswordStrengthRegularExpression="[0-9a-zA-Z]{6,12}$"/>
>> </providers>
>> </membership>

>
>



 
Reply With Quote
 
Dominick Baier [DevelopMentor]
Guest
Posts: n/a
 
      10-12-2005
Hello Roel,

the Initialize method is private in the Membership class

You have to implement the Initialize method in your MembershipProvider derived
class.

The NameValueCollection holds the configuration values from the <membership>
element in web.config, e.g. "RequiresQuestionAndAnwer=true" - you have to
parse the collection to set the internal state in your class and the properties.

as i said - take the time to read the whitepapers i gave you the link to
- without completely understanding the architecture, you won't have much
fun with your provider.
there you will also find the source code of the depracated Access provider
as a template.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

> There is no Membership.Initialize(); atleast not in asp.net 2 but i
> found a
> function Initialize in System.Web.Security.Membership.Provider. The
> parameter string name is clear thats te provider name but the other
> parameter is what i don't understand.
> public virtual void Initialize (
> string name,
> NameValueCollection config
> )"Dominick Baier [DevelopMentor]"
> <(E-Mail Removed)>
> wrote in message
> news:(E-Mail Removed). com...
>
>> Hello news.microsoft.com,
>>
>> the source looks like this (in the Membership class)
>>
>> public static bool RequiresQuestionAndAnswer
>> {
>> get
>> {
>> Membership.Initialize();
>> return Membership.Provider.RequiresQuestionAndAnswer;
>> }
>> }
>> Initialize loads the configured default provider and assigns the
>> instance to the Provider property. So - they read the value from the
>> currently loaded provider implementation - which is your custom
>> provider. You are responsible in your provider to implement a
>> Initialize method and read the values from the NameValueCollection
>> (to populate the properties).
>>
>> so - your scenario should work.
>>
>> you have to closely follow all the design pattern by microsoft - read
>> more
>> here:
>> http://msdn.microsoft.com/asp.net/be...s/default.aspx
>> ---------------------------------------
>> Dominick Baier - DevelopMentor
>> http://www.leastprivilege.com
>>> How can get the values of for example RequiresUniqueEmail from my
>>> own membershipprovider? Using is
>>> System.Web.Security.Membership.RequiresQuestionAnd Answer; is not an
>>> option because it will call the property from the membership
>>> provider.
>>>
>>> <membership userIsOnlineTimeWindow="15"
>>> defaultProvider="MembershipProviderSample">
>>> <providers>
>>> <add name="MembershipProviderSample"
>>> type="SecurityProviders.MembershipProviderSample"
>>> EnablePasswordReset="true"
>>> EnablePasswordRetrieval="true" MaxInvalidPasswordAttempts="5"
>>> MinRequiredNonAlphanumericCharacters="0"
>>> MinRequiredPasswordLength="6"
>>> MembershipPasswordFormat="Clear"
>>> RequiresQuestionAndAnswer="true"
>>> RequiresUniqueEmail="true"
>>> PasswordStrengthRegularExpression="[0-9a-zA-Z]{6,12}$"/>
>>> </providers>
>>> </membership>



 
Reply With Quote
 
Roel Veldhuizen
Guest
Posts: n/a
 
      10-12-2005
When rewritting Initialze you stil need to get that namevaluecollection. If
i have the namevaluecollection i can fix it. But how do i get the
namevaluecollection from the web.config?
I tried to us the ConfigurationManager but that didn't work.

"Dominick Baier [DevelopMentor]" <(E-Mail Removed)>
wrote in message news:(E-Mail Removed). com...
> Hello Roel,
>
> the Initialize method is private in the Membership class
>
> You have to implement the Initialize method in your MembershipProvider
> derived class.
>
> The NameValueCollection holds the configuration values from the
> <membership> element in web.config, e.g. "RequiresQuestionAndAnwer=true" -
> you have to parse the collection to set the internal state in your class
> and the properties.
>
> as i said - take the time to read the whitepapers i gave you the link to -
> without completely understanding the architecture, you won't have much fun
> with your provider.
> there you will also find the source code of the depracated Access provider
> as a template.
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>> There is no Membership.Initialize(); atleast not in asp.net 2 but i
>> found a
>> function Initialize in System.Web.Security.Membership.Provider. The
>> parameter string name is clear thats te provider name but the other
>> parameter is what i don't understand.
>> public virtual void Initialize (
>> string name,
>> NameValueCollection config
>> )"Dominick Baier [DevelopMentor]"
>> <(E-Mail Removed)>
>> wrote in message
>> news:(E-Mail Removed). com...
>>
>>> Hello news.microsoft.com,
>>>
>>> the source looks like this (in the Membership class)
>>>
>>> public static bool RequiresQuestionAndAnswer
>>> {
>>> get
>>> {
>>> Membership.Initialize();
>>> return Membership.Provider.RequiresQuestionAndAnswer;
>>> }
>>> }
>>> Initialize loads the configured default provider and assigns the
>>> instance to the Provider property. So - they read the value from the
>>> currently loaded provider implementation - which is your custom
>>> provider. You are responsible in your provider to implement a
>>> Initialize method and read the values from the NameValueCollection
>>> (to populate the properties).
>>>
>>> so - your scenario should work.
>>>
>>> you have to closely follow all the design pattern by microsoft - read
>>> more
>>> here:
>>> http://msdn.microsoft.com/asp.net/be...s/default.aspx
>>> ---------------------------------------
>>> Dominick Baier - DevelopMentor
>>> http://www.leastprivilege.com
>>>> How can get the values of for example RequiresUniqueEmail from my
>>>> own membershipprovider? Using is
>>>> System.Web.Security.Membership.RequiresQuestionAnd Answer; is not an
>>>> option because it will call the property from the membership
>>>> provider.
>>>>
>>>> <membership userIsOnlineTimeWindow="15"
>>>> defaultProvider="MembershipProviderSample">
>>>> <providers>
>>>> <add name="MembershipProviderSample"
>>>> type="SecurityProviders.MembershipProviderSample"
>>>> EnablePasswordReset="true"
>>>> EnablePasswordRetrieval="true" MaxInvalidPasswordAttempts="5"
>>>> MinRequiredNonAlphanumericCharacters="0"
>>>> MinRequiredPasswordLength="6"
>>>> MembershipPasswordFormat="Clear"
>>>> RequiresQuestionAndAnswer="true"
>>>> RequiresUniqueEmail="true"
>>>> PasswordStrengthRegularExpression="[0-9a-zA-Z]{6,12}$"/>
>>>> </providers>
>>>> </membership>

>
>



 
Reply With Quote
 
Roel Veldhuizen
Guest
Posts: n/a
 
      10-12-2005
I solved the problem
"Roel Veldhuizen" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> When rewritting Initialze you stil need to get that namevaluecollection.
> If i have the namevaluecollection i can fix it. But how do i get the
> namevaluecollection from the web.config?
> I tried to us the ConfigurationManager but that didn't work.
>
> "Dominick Baier [DevelopMentor]" <(E-Mail Removed)>
> wrote in message news:(E-Mail Removed). com...
>> Hello Roel,
>>
>> the Initialize method is private in the Membership class
>>
>> You have to implement the Initialize method in your MembershipProvider
>> derived class.
>>
>> The NameValueCollection holds the configuration values from the
>> <membership> element in web.config, e.g.
>> "RequiresQuestionAndAnwer=true" - you have to parse the collection to set
>> the internal state in your class and the properties.
>>
>> as i said - take the time to read the whitepapers i gave you the link
>> to - without completely understanding the architecture, you won't have
>> much fun with your provider.
>> there you will also find the source code of the depracated Access
>> provider as a template.
>>
>> ---------------------------------------
>> Dominick Baier - DevelopMentor
>> http://www.leastprivilege.com
>>
>>> There is no Membership.Initialize(); atleast not in asp.net 2 but i
>>> found a
>>> function Initialize in System.Web.Security.Membership.Provider. The
>>> parameter string name is clear thats te provider name but the other
>>> parameter is what i don't understand.
>>> public virtual void Initialize (
>>> string name,
>>> NameValueCollection config
>>> )"Dominick Baier [DevelopMentor]"
>>> <(E-Mail Removed)>
>>> wrote in message
>>> news:(E-Mail Removed). com...
>>>
>>>> Hello news.microsoft.com,
>>>>
>>>> the source looks like this (in the Membership class)
>>>>
>>>> public static bool RequiresQuestionAndAnswer
>>>> {
>>>> get
>>>> {
>>>> Membership.Initialize();
>>>> return Membership.Provider.RequiresQuestionAndAnswer;
>>>> }
>>>> }
>>>> Initialize loads the configured default provider and assigns the
>>>> instance to the Provider property. So - they read the value from the
>>>> currently loaded provider implementation - which is your custom
>>>> provider. You are responsible in your provider to implement a
>>>> Initialize method and read the values from the NameValueCollection
>>>> (to populate the properties).
>>>>
>>>> so - your scenario should work.
>>>>
>>>> you have to closely follow all the design pattern by microsoft - read
>>>> more
>>>> here:
>>>> http://msdn.microsoft.com/asp.net/be...s/default.aspx
>>>> ---------------------------------------
>>>> Dominick Baier - DevelopMentor
>>>> http://www.leastprivilege.com
>>>>> How can get the values of for example RequiresUniqueEmail from my
>>>>> own membershipprovider? Using is
>>>>> System.Web.Security.Membership.RequiresQuestionAnd Answer; is not an
>>>>> option because it will call the property from the membership
>>>>> provider.
>>>>>
>>>>> <membership userIsOnlineTimeWindow="15"
>>>>> defaultProvider="MembershipProviderSample">
>>>>> <providers>
>>>>> <add name="MembershipProviderSample"
>>>>> type="SecurityProviders.MembershipProviderSample"
>>>>> EnablePasswordReset="true"
>>>>> EnablePasswordRetrieval="true" MaxInvalidPasswordAttempts="5"
>>>>> MinRequiredNonAlphanumericCharacters="0"
>>>>> MinRequiredPasswordLength="6"
>>>>> MembershipPasswordFormat="Clear"
>>>>> RequiresQuestionAndAnswer="true"
>>>>> RequiresUniqueEmail="true"
>>>>> PasswordStrengthRegularExpression="[0-9a-zA-Z]{6,12}$"/>
>>>>> </providers>
>>>>> </membership>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Membership permissions after publishing an ASP.NET Membership site. Tino Donderwinkel ASP .Net 2 06-18-2008 08:16 AM
Membership or Role Provider // Provider Model // Factories .. How does MS do it? sloan ASP .Net 1 07-03-2007 08:17 PM
Deploying 2.0 app on a Service Provider .. Membership Provider sloan ASP .Net 5 06-03-2006 11:20 PM
Getting other data from Membership Provider Dave ASP .Net 4 03-22-2006 07:53 PM
Help setting up SQL Express as Membership Provider (ASP.NET 2.0 beta 2) Nate Hekman ASP .Net 0 04-25-2005 05:33 PM



Advertisments