Custom Membership Provider FullTrust Problem

Discussion in 'ASP .Net Security' started by Zeb, Jan 30, 2007.

  1. Zeb

    Zeb Guest

    Hi all.

    I've written a custom membership provider which works with tables in
    my ms sql database. This works great locally, but as soon as I run the
    site on the live (shared) server, I get the following error message:

    Parser Error Message: Attempt to access the method failed.

    The line in Web.Config that it's picked up on is as follows:


    Line 29: <providers>
    Line 30: <clear/>
    Line 31: <add name="AspNetCustomMembershipProvider"
    type="CustomMembershipProvider.CustomMembershipProvider"/>
    Line 32: </providers>
    Line 33: </membership>

    I've discovered that overriding the standard MembershipProvider
    requires Full Trust on the server and that one possible fix is to add
    the following to the top of my CustomMembershipProvider:

    [assembly: AllowPartiallyTrustedCallersAttribute()]


    However, when I do this, although the solution builds okay, I get the
    following error when I try to publish it:


    Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    attribute

    and it just points to a temporary file called App_Code.19.cs. I can't
    see where else this has been used.


    I've also played around with sn.exe to create a key and linked the
    project to it in the hope this would help, but this hasn't made any
    difference. I've asked my ISP if they can run the assemblies in Full
    Trust mode, but I don't suspect they'll want to.

    I've also read that I can use PermCalc to work out where the problem
    is, although I don't seem to have the SDK, so I might download that
    tonight and have a play.

    Any other ideas to point me in the right direction would be very much
    appreciated.


    Thanks!


    Matt
     
    Zeb, Jan 30, 2007
    #1
    1. Advertising

  2. Hi,

    first of all - you should set the trust level on your dev box to the same
    permissions as your hoster does.

    Next - make sure your provider is "public" - the provider factory can also
    instantiate non-public providers and that works fine in full trust - but
    not in partial trust

    Next - you only need AllowPartially... (APTCA) when the provider is strong
    named (is that the case?)

    Last - App_Codexx.cs is the source of the assembly compiled out of your App_Code
    directory (maybe you have APTCA set there somewhere)

    I would first of all factor the provider out in a separate assembly - no
    strong name and see what happens...


    -----
    Dominick Baier (http://www.leastprivilege.com)

    > Hi all.
    >
    > I've written a custom membership provider which works with tables in
    > my ms sql database. This works great locally, but as soon as I run the
    > site on the live (shared) server, I get the following error message:
    >
    > Parser Error Message: Attempt to access the method failed.
    >
    > The line in Web.Config that it's picked up on is as follows:
    >
    > Line 29: <providers>
    > Line 30: <clear/>
    > Line 31: <add name="AspNetCustomMembershipProvider"
    > type="CustomMembershipProvider.CustomMembershipProvider"/>
    > Line 32: </providers>
    > Line 33: </membership>
    > I've discovered that overriding the standard MembershipProvider
    > requires Full Trust on the server and that one possible fix is to add
    > the following to the top of my CustomMembershipProvider:
    >
    > [assembly: AllowPartiallyTrustedCallersAttribute()]
    >
    > However, when I do this, although the solution builds okay, I get the
    > following error when I try to publish it:
    >
    > Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    > attribute
    >
    > and it just points to a temporary file called App_Code.19.cs. I can't
    > see where else this has been used.
    >
    > I've also played around with sn.exe to create a key and linked the
    > project to it in the hope this would help, but this hasn't made any
    > difference. I've asked my ISP if they can run the assemblies in Full
    > Trust mode, but I don't suspect they'll want to.
    >
    > I've also read that I can use PermCalc to work out where the problem
    > is, although I don't seem to have the SDK, so I might download that
    > tonight and have a play.
    >
    > Any other ideas to point me in the right direction would be very much
    > appreciated.
    >
    > Thanks!
    >
    > Matt
    >
     
    Dominick Baier, Jan 30, 2007
    #2
    1. Advertising

  3. Zeb

    Zeb Guest

    Thanks for the advice Dominick.

    I'm now starting to feel a little out of my depth! :)

    1. How do you actually set the trust level of a site? Is this in the
    website properties in IIS?
    2. How do I make the provider public?
    3. I'm not sure if the provider is strong named. Do I simply do this
    by publishing with Strong Named Assemblies ticked?

    Something I've yet to get my head around with .net 2 is how assemblies
    are compiled. I'm still accustomed to the .net 1.1 way which results
    in a single dll to be uploaded to the server. .net 2 seems to create
    all kinds of assemblies in the bin folder. How do I single out the
    Provider into its own assembly?

    Sorry to be a pain and ask all these questions... I'm still learning
    about how the compiler works in .net 2 :)


    On 30 Jan, 10:17, Dominick Baier
    <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    > Hi,
    >
    > first of all - you should set the trust level on your dev box to the same
    > permissions as your hoster does.
    >
    > Next - make sure your provider is "public" - the provider factory can also
    > instantiate non-public providers and that works fine in full trust - but
    > not in partial trust
    >
    > Next - you only need AllowPartially... (APTCA) when the provider is strong
    > named (is that the case?)
    >
    > Last - App_Codexx.cs is the source of the assembly compiled out of your App_Code
    > directory (maybe you have APTCA set there somewhere)
    >
    > I would first of all factor the provider out in a separate assembly - no
    > strong name and see what happens...
    >
    > -----
    > Dominick Baier (http://www.leastprivilege.com)
    >
    >
    >
    > > Hi all.

    >
    > > I've written a custom membership provider which works with tables in
    > > my ms sql database. This works great locally, but as soon as I run the
    > > site on the live (shared) server, I get the following error message:

    >
    > > Parser Error Message: Attempt to access the method failed.

    >
    > > The line in Web.Config that it's picked up on is as follows:

    >
    > > Line 29: <providers>
    > > Line 30: <clear/>
    > > Line 31: <add name="AspNetCustomMembershipProvider"
    > > type="CustomMembershipProvider.CustomMembershipProvider"/>
    > > Line 32: </providers>
    > > Line 33: </membership>
    > > I've discovered that overriding the standard MembershipProvider
    > > requires Full Trust on the server and that one possible fix is to add
    > > the following to the top of my CustomMembershipProvider:

    >
    > > [assembly: AllowPartiallyTrustedCallersAttribute()]

    >
    > > However, when I do this, although the solution builds okay, I get the
    > > following error when I try to publish it:

    >
    > > Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    > > attribute

    >
    > > and it just points to a temporary file called App_Code.19.cs. I can't
    > > see where else this has been used.

    >
    > > I've also played around with sn.exe to create a key and linked the
    > > project to it in the hope this would help, but this hasn't made any
    > > difference. I've asked my ISP if they can run the assemblies in Full
    > > Trust mode, but I don't suspect they'll want to.

    >
    > > I've also read that I can use PermCalc to work out where the problem
    > > is, although I don't seem to have the SDK, so I might download that
    > > tonight and have a play.

    >
    > > Any other ideas to point me in the right direction would be very much
    > > appreciated.

    >
    > > Thanks!

    >
    > > Matt- Hide quoted text -- Show quoted text -
     
    Zeb, Jan 30, 2007
    #3
  4. hi,

    ok - a little ambitious to start with partial trust ;)

    1. the <trust> level in web.config
    2. public CustomMembershipProvider
    3. it depends...

    compilation is different - but easy - pages/controls are compiled by demand
    (or pre-compiled) -

    all code in App_Code gets compiled into an assembly called App_Code.

    You can still just write code in a separate class library and deploy the
    ..dll to /bin...

    a quick google is also always helpful ;)
    http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/

    -----
    Dominick Baier (http://www.leastprivilege.com)

    > Thanks for the advice Dominick.
    >
    > I'm now starting to feel a little out of my depth! :)
    >
    > 1. How do you actually set the trust level of a site? Is this in the
    > website properties in IIS?
    > 2. How do I make the provider public?
    > 3. I'm not sure if the provider is strong named. Do I simply do this
    > by publishing with Strong Named Assemblies ticked?
    > Something I've yet to get my head around with .net 2 is how assemblies
    > are compiled. I'm still accustomed to the .net 1.1 way which results
    > in a single dll to be uploaded to the server. .net 2 seems to create
    > all kinds of assemblies in the bin folder. How do I single out the
    > Provider into its own assembly?
    >
    > Sorry to be a pain and ask all these questions... I'm still learning
    > about how the compiler works in .net 2 :)
    >
    > On 30 Jan, 10:17, Dominick Baier
    > <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    >
    >> Hi,
    >>
    >> first of all - you should set the trust level on your dev box to the
    >> same permissions as your hoster does.
    >>
    >> Next - make sure your provider is "public" - the provider factory can
    >> also instantiate non-public providers and that works fine in full
    >> trust - but not in partial trust
    >>
    >> Next - you only need AllowPartially... (APTCA) when the provider is
    >> strong named (is that the case?)
    >>
    >> Last - App_Codexx.cs is the source of the assembly compiled out of
    >> your App_Code directory (maybe you have APTCA set there somewhere)
    >>
    >> I would first of all factor the provider out in a separate assembly -
    >> no strong name and see what happens...
    >>
    >> -----
    >> Dominick Baier (http://www.leastprivilege.com)
    >>> Hi all.
    >>>
    >>> I've written a custom membership provider which works with tables in
    >>> my ms sql database. This works great locally, but as soon as I run
    >>> the site on the live (shared) server, I get the following error
    >>> message:
    >>>
    >>> Parser Error Message: Attempt to access the method failed.
    >>>
    >>> The line in Web.Config that it's picked up on is as follows:
    >>>
    >>> Line 29: <providers>
    >>> Line 30: <clear/>
    >>> Line 31: <add name="AspNetCustomMembershipProvider"
    >>> type="CustomMembershipProvider.CustomMembershipProvider"/>
    >>> Line 32: </providers>
    >>> Line 33: </membership>
    >>> I've discovered that overriding the standard MembershipProvider
    >>> requires Full Trust on the server and that one possible fix is to
    >>> add
    >>> the following to the top of my CustomMembershipProvider:
    >>> [assembly: AllowPartiallyTrustedCallersAttribute()]
    >>>
    >>> However, when I do this, although the solution builds okay, I get
    >>> the following error when I try to publish it:
    >>>
    >>> Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    >>> attribute
    >>>
    >>> and it just points to a temporary file called App_Code.19.cs. I
    >>> can't see where else this has been used.
    >>>
    >>> I've also played around with sn.exe to create a key and linked the
    >>> project to it in the hope this would help, but this hasn't made any
    >>> difference. I've asked my ISP if they can run the assemblies in Full
    >>> Trust mode, but I don't suspect they'll want to.
    >>>
    >>> I've also read that I can use PermCalc to work out where the problem
    >>> is, although I don't seem to have the SDK, so I might download that
    >>> tonight and have a play.
    >>>
    >>> Any other ideas to point me in the right direction would be very
    >>> much appreciated.
    >>>
    >>> Thanks!
    >>>
    >>> Matt- Hide quoted text -- Show quoted text -
    >>>
     
    Dominick Baier, Jan 30, 2007
    #4
  5. Zeb

    Zeb Guest

    Excellent .. thanks again for the info!

    I'll start off by making sure the provider is public and see if that
    has an effect.

    Thanks for the link. Looks like a very useful article. I did start out
    trying to define the custom provider in a seperate class library, but
    ran into problems because it needs access to methods in the business
    logic layer, which are held in the main project. So it became very
    tricky to seperate it out.

    Hopefully making the provider public will do the trick .. hopefully!
    Worth a shot anyway.

    The other thing I was going to try is to use the PermCalc tool that
    I've seen mentioned a lot online. I'm downloading the .net 2 SDK at
    the moment in the hope that it's included.

    Thanks again.

    On 30 Jan, 13:02, Dominick Baier
    <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    > hi,
    >
    > ok - a little ambitious to start with partial trust ;)
    >
    > 1. the <trust> level in web.config
    > 2. public CustomMembershipProvider
    > 3. it depends...
    >
    > compilation is different - but easy - pages/controls are compiled by demand
    > (or pre-compiled) -
    >
    > all code in App_Code gets compiled into an assembly called App_Code.
    >
    > You can still just write code in a separate class library and deploy the
    > .dll to /bin...
    >
    > a quick google is also always helpful ;)http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/
    >
    > -----
    > Dominick Baier (http://www.leastprivilege.com)
    >
    >
    >
    > > Thanks for the advice Dominick.

    >
    > > I'm now starting to feel a little out of my depth! :)

    >
    > > 1. How do you actually set the trust level of a site? Is this in the
    > > website properties in IIS?
    > > 2. How do I make the provider public?
    > > 3. I'm not sure if the provider is strong named. Do I simply do this
    > > by publishing with Strong Named Assemblies ticked?
    > > Something I've yet to get my head around with .net 2 is how assemblies
    > > are compiled. I'm still accustomed to the .net 1.1 way which results
    > > in a single dll to be uploaded to the server. .net 2 seems to create
    > > all kinds of assemblies in the bin folder. How do I single out the
    > > Provider into its own assembly?

    >
    > > Sorry to be a pain and ask all these questions... I'm still learning
    > > about how the compiler works in .net 2 :)

    >
    > > On 30 Jan, 10:17, Dominick Baier
    > > <dbaier@pleasepleasenospam_leastprivilege.com> wrote:

    >
    > >> Hi,

    >
    > >> first of all - you should set the trust level on your dev box to the
    > >> same permissions as your hoster does.

    >
    > >> Next - make sure your provider is "public" - the provider factory can
    > >> also instantiate non-public providers and that works fine in full
    > >> trust - but not in partial trust

    >
    > >> Next - you only need AllowPartially... (APTCA) when the provider is
    > >> strong named (is that the case?)

    >
    > >> Last - App_Codexx.cs is the source of the assembly compiled out of
    > >> your App_Code directory (maybe you have APTCA set there somewhere)

    >
    > >> I would first of all factor the provider out in a separate assembly -
    > >> no strong name and see what happens...

    >
    > >> -----
    > >> Dominick Baier (http://www.leastprivilege.com)
    > >>> Hi all.

    >
    > >>> I've written a custom membership provider which works with tables in
    > >>> my ms sql database. This works great locally, but as soon as I run
    > >>> the site on the live (shared) server, I get the following error
    > >>> message:

    >
    > >>> Parser Error Message: Attempt to access the method failed.

    >
    > >>> The line in Web.Config that it's picked up on is as follows:

    >
    > >>> Line 29: <providers>
    > >>> Line 30: <clear/>
    > >>> Line 31: <add name="AspNetCustomMembershipProvider"
    > >>> type="CustomMembershipProvider.CustomMembershipProvider"/>
    > >>> Line 32: </providers>
    > >>> Line 33: </membership>
    > >>> I've discovered that overriding the standard MembershipProvider
    > >>> requires Full Trust on the server and that one possible fix is to
    > >>> add
    > >>> the following to the top of my CustomMembershipProvider:
    > >>> [assembly: AllowPartiallyTrustedCallersAttribute()]

    >
    > >>> However, when I do this, although the solution builds okay, I get
    > >>> the following error when I try to publish it:

    >
    > >>> Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    > >>> attribute

    >
    > >>> and it just points to a temporary file called App_Code.19.cs. I
    > >>> can't see where else this has been used.

    >
    > >>> I've also played around with sn.exe to create a key and linked the
    > >>> project to it in the hope this would help, but this hasn't made any
    > >>> difference. I've asked my ISP if they can run the assemblies in Full
    > >>> Trust mode, but I don't suspect they'll want to.

    >
    > >>> I've also read that I can use PermCalc to work out where the problem
    > >>> is, although I don't seem to have the SDK, so I might download that
    > >>> tonight and have a play.

    >
    > >>> Any other ideas to point me in the right direction would be very
    > >>> much appreciated.

    >
    > >>> Thanks!

    >
    > >>> Matt- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -
     
    Zeb, Jan 30, 2007
    #5
  6. permcalc is near to useless IMO...


    -----
    Dominick Baier (http://www.leastprivilege.com)

    > Excellent .. thanks again for the info!
    >
    > I'll start off by making sure the provider is public and see if that
    > has an effect.
    >
    > Thanks for the link. Looks like a very useful article. I did start out
    > trying to define the custom provider in a seperate class library, but
    > ran into problems because it needs access to methods in the business
    > logic layer, which are held in the main project. So it became very
    > tricky to seperate it out.
    >
    > Hopefully making the provider public will do the trick .. hopefully!
    > Worth a shot anyway.
    >
    > The other thing I was going to try is to use the PermCalc tool that
    > I've seen mentioned a lot online. I'm downloading the .net 2 SDK at
    > the moment in the hope that it's included.
    >
    > Thanks again.
    >
    > On 30 Jan, 13:02, Dominick Baier
    > <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    >
    >> hi,
    >>
    >> ok - a little ambitious to start with partial trust ;)
    >>
    >> 1. the <trust> level in web.config
    >> 2. public CustomMembershipProvider
    >> 3. it depends...
    >> compilation is different - but easy - pages/controls are compiled by
    >> demand (or pre-compiled) -
    >>
    >> all code in App_Code gets compiled into an assembly called App_Code.
    >>
    >> You can still just write code in a separate class library and deploy
    >> the .dll to /bin...
    >>
    >> a quick google is also always helpful
    >> ;)http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/
    >>
    >> -----
    >> Dominick Baier (http://www.leastprivilege.com)
    >>> Thanks for the advice Dominick.
    >>>
    >>> I'm now starting to feel a little out of my depth! :)
    >>>
    >>> 1. How do you actually set the trust level of a site? Is this in the
    >>> website properties in IIS?
    >>> 2. How do I make the provider public?
    >>> 3. I'm not sure if the provider is strong named. Do I simply do this
    >>> by publishing with Strong Named Assemblies ticked?
    >>> Something I've yet to get my head around with .net 2 is how
    >>> assemblies
    >>> are compiled. I'm still accustomed to the .net 1.1 way which results
    >>> in a single dll to be uploaded to the server. .net 2 seems to create
    >>> all kinds of assemblies in the bin folder. How do I single out the
    >>> Provider into its own assembly?
    >>> Sorry to be a pain and ask all these questions... I'm still learning
    >>> about how the compiler works in .net 2 :)
    >>>
    >>> On 30 Jan, 10:17, Dominick Baier
    >>> <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    >>>> Hi,
    >>>>
    >>>> first of all - you should set the trust level on your dev box to
    >>>> the same permissions as your hoster does.
    >>>>
    >>>> Next - make sure your provider is "public" - the provider factory
    >>>> can also instantiate non-public providers and that works fine in
    >>>> full trust - but not in partial trust
    >>>>
    >>>> Next - you only need AllowPartially... (APTCA) when the provider is
    >>>> strong named (is that the case?)
    >>>>
    >>>> Last - App_Codexx.cs is the source of the assembly compiled out of
    >>>> your App_Code directory (maybe you have APTCA set there somewhere)
    >>>>
    >>>> I would first of all factor the provider out in a separate assembly
    >>>> - no strong name and see what happens...
    >>>>
    >>>> -----
    >>>> Dominick Baier (http://www.leastprivilege.com)
    >>>>> Hi all.
    >>>>>
    >>>>> I've written a custom membership provider which works with tables
    >>>>> in my ms sql database. This works great locally, but as soon as I
    >>>>> run the site on the live (shared) server, I get the following
    >>>>> error message:
    >>>>>
    >>>>> Parser Error Message: Attempt to access the method failed.
    >>>>>
    >>>>> The line in Web.Config that it's picked up on is as follows:
    >>>>>
    >>>>> Line 29: <providers>
    >>>>> Line 30: <clear/>
    >>>>> Line 31: <add name="AspNetCustomMembershipProvider"
    >>>>> type="CustomMembershipProvider.CustomMembershipProvider"/>
    >>>>> Line 32: </providers>
    >>>>> Line 33: </membership>
    >>>>> I've discovered that overriding the standard MembershipProvider
    >>>>> requires Full Trust on the server and that one possible fix is to
    >>>>> add
    >>>>> the following to the top of my CustomMembershipProvider:
    >>>>> [assembly: AllowPartiallyTrustedCallersAttribute()]
    >>>>> However, when I do this, although the solution builds okay, I get
    >>>>> the following error when I try to publish it:
    >>>>>
    >>>>> Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    >>>>> attribute
    >>>>>
    >>>>> and it just points to a temporary file called App_Code.19.cs. I
    >>>>> can't see where else this has been used.
    >>>>>
    >>>>> I've also played around with sn.exe to create a key and linked the
    >>>>> project to it in the hope this would help, but this hasn't made
    >>>>> any difference. I've asked my ISP if they can run the assemblies
    >>>>> in Full Trust mode, but I don't suspect they'll want to.
    >>>>>
    >>>>> I've also read that I can use PermCalc to work out where the
    >>>>> problem is, although I don't seem to have the SDK, so I might
    >>>>> download that tonight and have a play.
    >>>>>
    >>>>> Any other ideas to point me in the right direction would be very
    >>>>> much appreciated.
    >>>>>
    >>>>> Thanks!
    >>>>>
    >>>>> Matt- Hide quoted text -- Show quoted text -- Hide quoted text --
    >>>>> Show quoted text -
    >>>>>
     
    Dominick Baier, Jan 30, 2007
    #6
  7. Zeb

    Zeb Guest

    Hehe okay .. I'll leave that as a last resort then! :)

    On 30 Jan, 14:13, Dominick Baier
    <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    > permcalc is near to useless IMO...
    >
    > -----
    > Dominick Baier (http://www.leastprivilege.com)
    >
    >
    >
    > > Excellent .. thanks again for the info!

    >
    > > I'll start off by making sure the provider is public and see if that
    > > has an effect.

    >
    > > Thanks for the link. Looks like a very useful article. I did start out
    > > trying to define the custom provider in a seperate class library, but
    > > ran into problems because it needs access to methods in the business
    > > logic layer, which are held in the main project. So it became very
    > > tricky to seperate it out.

    >
    > > Hopefully making the provider public will do the trick .. hopefully!
    > > Worth a shot anyway.

    >
    > > The other thing I was going to try is to use the PermCalc tool that
    > > I've seen mentioned a lot online. I'm downloading the .net 2 SDK at
    > > the moment in the hope that it's included.

    >
    > > Thanks again.

    >
    > > On 30 Jan, 13:02, Dominick Baier
    > > <dbaier@pleasepleasenospam_leastprivilege.com> wrote:

    >
    > >> hi,

    >
    > >> ok - a little ambitious to start with partial trust ;)

    >
    > >> 1. the <trust> level in web.config
    > >> 2. public CustomMembershipProvider
    > >> 3. it depends...
    > >> compilation is different - but easy - pages/controls are compiled by
    > >> demand (or pre-compiled) -

    >
    > >> all code in App_Code gets compiled into an assembly called App_Code.

    >
    > >> You can still just write code in a separate class library and deploy
    > >> the .dll to /bin...

    >
    > >> a quick google is also always helpful
    > >> ;)http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/

    >
    > >> -----
    > >> Dominick Baier (http://www.leastprivilege.com)
    > >>> Thanks for the advice Dominick.

    >
    > >>> I'm now starting to feel a little out of my depth! :)

    >
    > >>> 1. How do you actually set the trust level of a site? Is this in the
    > >>> website properties in IIS?
    > >>> 2. How do I make the provider public?
    > >>> 3. I'm not sure if the provider is strong named. Do I simply do this
    > >>> by publishing with Strong Named Assemblies ticked?
    > >>> Something I've yet to get my head around with .net 2 is how
    > >>> assemblies
    > >>> are compiled. I'm still accustomed to the .net 1.1 way which results
    > >>> in a single dll to be uploaded to the server. .net 2 seems to create
    > >>> all kinds of assemblies in the bin folder. How do I single out the
    > >>> Provider into its own assembly?
    > >>> Sorry to be a pain and ask all these questions... I'm still learning
    > >>> about how the compiler works in .net 2 :)

    >
    > >>> On 30 Jan, 10:17, Dominick Baier
    > >>> <dbaier@pleasepleasenospam_leastprivilege.com> wrote:
    > >>>> Hi,

    >
    > >>>> first of all - you should set the trust level on your dev box to
    > >>>> the same permissions as your hoster does.

    >
    > >>>> Next - make sure your provider is "public" - the provider factory
    > >>>> can also instantiate non-public providers and that works fine in
    > >>>> full trust - but not in partial trust

    >
    > >>>> Next - you only need AllowPartially... (APTCA) when the provider is
    > >>>> strong named (is that the case?)

    >
    > >>>> Last - App_Codexx.cs is the source of the assembly compiled out of
    > >>>> your App_Code directory (maybe you have APTCA set there somewhere)

    >
    > >>>> I would first of all factor the provider out in a separate assembly
    > >>>> - no strong name and see what happens...

    >
    > >>>> -----
    > >>>> Dominick Baier (http://www.leastprivilege.com)
    > >>>>> Hi all.

    >
    > >>>>> I've written a custom membership provider which works with tables
    > >>>>> in my ms sql database. This works great locally, but as soon as I
    > >>>>> run the site on the live (shared) server, I get the following
    > >>>>> error message:

    >
    > >>>>> Parser Error Message: Attempt to access the method failed.

    >
    > >>>>> The line in Web.Config that it's picked up on is as follows:

    >
    > >>>>> Line 29: <providers>
    > >>>>> Line 30: <clear/>
    > >>>>> Line 31: <add name="AspNetCustomMembershipProvider"
    > >>>>> type="CustomMembershipProvider.CustomMembershipProvider"/>
    > >>>>> Line 32: </providers>
    > >>>>> Line 33: </membership>
    > >>>>> I've discovered that overriding the standard MembershipProvider
    > >>>>> requires Full Trust on the server and that one possible fix is to
    > >>>>> add
    > >>>>> the following to the top of my CustomMembershipProvider:
    > >>>>> [assembly: AllowPartiallyTrustedCallersAttribute()]
    > >>>>> However, when I do this, although the solution builds okay, I get
    > >>>>> the following error when I try to publish it:

    >
    > >>>>> Duplicate 'System.Security.AllowPartiallyTrustedCallersAttribute'
    > >>>>> attribute

    >
    > >>>>> and it just points to a temporary file called App_Code.19.cs. I
    > >>>>> can't see where else this has been used.

    >
    > >>>>> I've also played around with sn.exe to create a key and linked the
    > >>>>> project to it in the hope this would help, but this hasn't made
    > >>>>> any difference. I've asked my ISP if they can run the assemblies
    > >>>>> in Full Trust mode, but I don't suspect they'll want to.

    >
    > >>>>> I've also read that I can use PermCalc to work out where the
    > >>>>> problem is, although I don't seem to have the SDK, so I might
    > >>>>> download that tonight and have a play.

    >
    > >>>>> Any other ideas to point me in the right direction would be very
    > >>>>> much appreciated.

    >
    > >>>>> Thanks!

    >
    > >>>>> Matt- Hide quoted text -- Show quoted text -- Hide quoted text --
    > >>>>> Show quoted text -- Hide quoted text -- Show quoted text -
     
    Zeb, Jan 30, 2007
    #7
  8. Zeb

    Zeb Guest

    lol .. I just made the provider public and it worked! So simple when
    you know how. Now I need to just invest some time in understanding
    why! :)

    Thanks for your hellp Dominic .. you've been very helpful!!


    Matt
     
    Zeb, Jan 30, 2007
    #8
    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. sloan
    Replies:
    5
    Views:
    1,515
    sloan
    Jun 4, 2006
  2. Replies:
    0
    Views:
    747
  3. sloan
    Replies:
    1
    Views:
    514
    Chad Scharf
    Jul 3, 2007
  4. Wendy

    Gaining FullTrust

    Wendy, Jun 22, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    118
    Wendy
    Jun 22, 2004
  5. Brett Ossman

    Custom Membership Provider - Custom Error Messages

    Brett Ossman, Mar 11, 2009, in forum: ASP .Net Security
    Replies:
    0
    Views:
    790
    Brett Ossman
    Mar 11, 2009
Loading...

Share This Page