Question

When customers visit my site, a guid is being passed in which tells me what company they can log into.

I would like each company to have it's own set of logins based on the application.

I was hoping to make an application for each company based on this guid that is being passed in.

Can the applicationName be changed, prior to accessing the AspNetSqlMembershipProvider, so that it ties the users to that application?

<membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider"
         type="System.Web.Security.SqlMembershipProvider"
         connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="true"
         requiresUniqueEmail="true"
         maxInvalidPasswordAttempts="3"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="webportal"/>
  </providers>
</membership>

I cannot change it in the config from code since that would affect the other users... so, can it be done programmatically once I get their guid?

Thanks for the help!

Was it helpful?

Solution

you can not edit the contents of the web.config file dynamically. What you can do is put several different providers in the web.config - even if the only difference is the application name. Then dynamically choose which provider you want dynamically like this:

Membership.Providers["MyOtherProvider"].ValidateUser(username, pwd);

then in web.config

<membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider"
         type="System.Web.Security.SqlMembershipProvider"
         connectionStringName="ApplicationServices"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="true"
         requiresUniqueEmail="true"
         maxInvalidPasswordAttempts="3"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         applicationName="webportal"/>

  <add name="MyOtherProvider" ...
   ...
  />
  </providers>
</membership>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top