Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > ProfileCommon.Create creates user with wrong apllicationID (provider)

Reply
Thread Tools

ProfileCommon.Create creates user with wrong apllicationID (provider)

 
 
news.microsoft.com
Guest
Posts: n/a
 
      12-11-2008
I have this code that should save a user with a specific applicationID:

protected void btnSaveUser_Click(object sender, EventArgs e)
{
string username = this.txtUsername.Text;
string firstname = this.txtFirstname.Text;
string lastname = this.txtLastname.Text;
string password = this.txtPassword.Text;
string email = this.txtEmail.Text;
int siteId = int.Parse(this.txtSiteId.Text);

MembershipCreateStatus status;
MembershipProvider mp = Membership.Providers[siteId.ToString()];
MembershipUser user = mp.CreateUser(username, password, email, null,
null, true, null, out status);

ProfileCommon p = (ProfileCommon)ProfileCommon.Create(user.UserName,
true);
p.FirstName = firstname;
p.LastName = lastname;
p.Save();

if (status == MembershipCreateStatus.Success)
{
// party!
}
}

In web.config I have 2 different applications (providers) like this:

<membership defaultProvider="1" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="1" applicationName="1"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ConnString" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"/>
<add name="2" applicationName="2"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ConnString" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"/>
</providers>
</membership>
<roleManager defaultProvider="1" enabled="false" cacheRolesInCookie="false"
cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/"
cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All" createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear />
<add name="1" applicationName="1" connectionStringName="ConnString"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="2" applicationName="2" connectionStringName="ConnString"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<profile enabled="true" defaultProvider="1">
<providers>
<clear/>
<add name="1" applicationName="1"
type="Microsoft.Samples.SqlStoredProcedureProfileP rovider"
connectionStringName="ConnString" setProcedure="setCustomProfileData"
readProcedure="getCustomProfileData" />
<add name="2" applicationName="2"
type="Microsoft.Samples.SqlStoredProcedureProfileP rovider"
connectionStringName="ConnString" setProcedure="setCustomProfileData"
readProcedure="getCustomProfileData" />
</providers>
<properties>
<add name="FirstName" defaultValue="[null]"
customProviderData="FirstName;nvarchar;50"/>
<add name="LastName" defaultValue="[null]"
customProviderData="LastName;nvarchar;50"/>
<add name="Age" type="int" customProviderData="Age;int;1"/>
</properties>
</profile>


If siteID=2 (this.txtSiteId.Text) then the users shall have applicationID=2.
It works when running mp.CreateUser();

But, when running ProfileCommon.Create() the default applicationID from
web.config is used (1), and a new user is created in the aspnet_users tabell
with applicationID 1. The profiledata is then related to this user that
should never been created, not the correct user with applicationID=2.

How can I programmatically set the correct provider (applicationID) when
saving profiledata (ProfileCommon.Create())?

Thanks for all tips!!!


 
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
Visual Studio creates UserControls as wrong type Carlo Razzeto ASP .Net 1 11-10-2006 11:19 PM
Re: Firewire card creates dial-up internet access conflict. Dead Meat Wireless Networking 0 09-02-2004 01:15 AM
vs.net creates doctype wrong? Ian ASP .Net 2 06-21-2004 12:32 PM
Application creates IWAM_<machinename> user profile? \Rob\ ASP .Net 1 05-09-2004 12:59 PM
CGI upload creates empty file on server? Kristian Perl 1 10-21-2003 05:06 PM



Advertisments