IPrincipal and IIdentity

Source: Internet
Author: User
Tags httpcontext

IPrincipal and IIdentity
IPrincipal: The user object represents the user's security context, and the code is currently running on behalf of the user, including the user's logo (iidentity) and any roles they belong to. All user objects need to implement the

IPrincipal. (Note in MSDN)
If you want to apply user role authentication to existing ASP.net applications, you can use IPrincipal to customize a customprincipal to implement user role verification.
IIdentity:
Defines the basic function of a marked object, representing a specific user whose code is currently running on behalf of the user.
(Note in MSDN)

IPrincipal and IIdentity can be found in the context of the ASP.net program instance.
It is common practice to:
asp.net application in the membership class to achieve the IIdentity excuse, and then CustomPrincipal class through a combination of the package of the member class, while CustomPrincipal implementation of the IPrincipal interface;
When the current code gets the user's mark, the most straightforward approach is to call the HttpContext.Current.User interface directly (it has always been thought that HttpContext.Current.User is a class and later found that it is an interface.) ),

HttpContext.Current.User interface in the default context, I'm not sure which class is coming from, but the HttpContext.Current.User interface can be assigned, so that after instantiating CustomPrincipal,

Assignment to the HttpContext.Current.User interface. An assignment can be placed in a AuthenticateRequest event in a HttpApplication instance.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.