Getting attributs for membership provider from web.config

Discussion in 'ASP .Net Security' started by news.microsoft.com, Oct 12, 2005.

  1. How can get the values of for example RequiresUniqueEmail from my own
    membershipprovider? Using is
    System.Web.Security.Membership.RequiresQuestionAndAnswer; 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>
     
    news.microsoft.com, Oct 12, 2005
    #1
    1. Advertising

  2. 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/beta2/providers/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.RequiresQuestionAndAnswer; 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>
     
    Dominick Baier [DevelopMentor], Oct 12, 2005
    #2
    1. Advertising

  3. 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]" <>
    wrote in message news:...
    > 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/beta2/providers/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.RequiresQuestionAndAnswer; 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>

    >
    >
     
    Roel Veldhuizen, Oct 12, 2005
    #3
  4. 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]"
    > <>
    > wrote in message
    > news:...
    >
    >> 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/beta2/providers/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.RequiresQuestionAndAnswer; 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>
     
    Dominick Baier [DevelopMentor], Oct 12, 2005
    #4
  5. 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]" <>
    wrote in message news:...
    > 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]"
    >> <>
    >> wrote in message
    >> news:...
    >>
    >>> 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/beta2/providers/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.RequiresQuestionAndAnswer; 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>

    >
    >
     
    Roel Veldhuizen, Oct 12, 2005
    #5
  6. I solved the problem
    "Roel Veldhuizen" <> wrote in message
    news:%...
    > 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]" <>
    > wrote in message news:...
    >> 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]"
    >>> <>
    >>> wrote in message
    >>> news:...
    >>>
    >>>> 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/beta2/providers/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.RequiresQuestionAndAnswer; 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>

    >>
    >>

    >
    >
     
    Roel Veldhuizen, Oct 12, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    4
    Views:
    534
    clintonG
    Mar 22, 2006
  2. sloan
    Replies:
    5
    Views:
    1,512
    sloan
    Jun 4, 2006
  3. CSharpner
    Replies:
    0
    Views:
    1,044
    CSharpner
    Apr 9, 2007
  4. sloan
    Replies:
    1
    Views:
    512
    Chad Scharf
    Jul 3, 2007
  5. JimLad
    Replies:
    2
    Views:
    814
    JimLad
    Jan 20, 2010
Loading...

Share This Page