The relationship between MembershipUser and IPrincipal

I assume that the object and the MembershipUser object that implements the IPrincipal interface are β€œconnected” in a sense, that when certain information changes in one of the objects, the other object also changes accordingly?

+7
authentication forms-authentication asp.net-membership
source share
1 answer

Not sure if I understand your question here, but I think your assumption is wrong.

MemberhipUser is used by System.Web.Security to authenticate the User through the MembershipProvider that you set in your web configuration. When you call ...

MembershipUser user = Membership.GetUser(username); 

Your member provider will request a data store where you store user information (Sql database, Active Directory, etc.) and return Memberhsip sotred data for that username.

If you define another class in your application that implements the IPrincipal interface, and you instantiate an object of this type, this does not necessarily mean that your MembershipUser object and your data about the object’s shared resources (unless, of course, you assigned the link programmatically)

Perhaps if you provided a sample code, this will help clarify

+4
source share

All Articles