Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

multiple profile providers in single web application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 27 Jun 2007 19:25 GMT
Hi:

I have been trying to create a web application that provides suport
for two membership/profile databases: one for private users and one
for another set of users.  These tw user have a totally different set
of profile attributes.

I added the following code to my web.config (under system.web):

<membership defaultProvider="PortalMembershipProvider">
 <providers>
   <remove name="PortalMembershipProvider"/>
   <remove name="PublicMembershipProvider"/>
   <add name="PortalMembershipProvider"
type="System.Web.Security.SqlMembershipProvider..."
connectionStringName="LocalSqlServer" .../>
   <add name="PublicMembershipProvider"
type="System.Web.Security.SqlMembershipProvider..."
connectionStringName="PublicUserProfiles" .../>
 </providers>
</membership>
<profile defaultProvider="PortalProfileProvider">
 <providers>
   <remove name="PortalProfileProvider"/>
   <remove name="PublicProfileProvider"/>
   <add name="PortalProfileProvider"
connectionStringName="LocalSqlServer" .../>
   <add name="PublicProfileProvider"
connectionStringName="PublicUserProfiles" .../>
 </providers>
 <properties>
   <add provider="PortalProfileProvider" name="FirstName"
type="System.String" serializeAs="Xml"/>
   <add provider="PortalProfileProvider" name="LastName"
type="System.String" serializeAs="Xml"/>
   <group name="PhoneNumbers">
     <add provider="PublicProfileProvider" name="Phone"
type="System.String" serializeAs="Xml"/>
     <add provider="PublicProfileProvider" name="Fax"
type="System.String" serializeAs="Xml"/>
   </group>
 </properties>
</profile>
<roleManager defaultProvider="PortalRoleProvider" enabled="true">
 <providers>
   <add name="PortalRoleProvider"
connectionStringName="LocalSqlServer" .../>
   <add name="PublicRoleProvider"
connectionStringName="PublicUserProfiles" .../>
 </providers>
</roleManager>

All connection string names and values have been verified.

I try to add a user via the Membership API, targeting a specific
provider from above, I use the following code:
     MembershipCreateStatus status;
     user =
Membership.Providers["PortalMembershipProvider"].CreateUser(username,
password, email, "", "", true, Guid.NewGuid(), out status);
This works without issue.

I do the same ting for adding the new user to a role:

Roles.Providers["PortalRoleProvider"].AddUsersToRoles(userStringArray,
roleStringArray);
This works without issue as well.

Now here is the problem.  When I try to perform a similar action to
add a profile for the new user, I use the following code:
    section =
(ProfileSection)WebConfigurationManager.GetSection("system.web/
profile");
    profile.Providers["PortalProfileProvider"].Initialize(

user.UserName,

section.Providers["PortalProfileProvider"].Parameters
                                                           );

I recieve an error stating that the profile provider "reference is not
set to an instance of an object."

Is there any way to get around this?

Best Regards,
Mike
Jon  Paal [MSMD] - 27 Jun 2007 21:23 GMT
one profile, use fields as needed with 2 roles....

> Hi:
>
> I have been trying to create a web application that provides suport
> for two membership/profile databases: one for private users and one
> for another set of users.  These tw user have a totally different set
> of profile attributes.>
...
> Is there any way to get around this?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.