Community Server Series 9: User Management 1 (memberrole) in CS2)

Source: Internet
Author: User

recently, due to physical and mental discomfort, it has not been updated. Now I have picked up the pen and continued this series ......
Users and permission management in Cs are complex. It is essential to understand the users and permission-Related Mechanisms of CS, now we will give a brief introduction to the user management machine in CS.
CS is in ASP. in the net1.1 era, although the permission mechanism used in the CS1 series is built on Microsoft memberrole1.0, it still follows this module in CS2. However, we can see that CS2 has implemented two solutions for asp1.1 and asp2.0, so that we can use memberrole1.0 in. net1.1 State to use the memberrole that comes with ASP. net2.0 in. net2.0 state. In CS2, how can we achieve such flexible configuration? Here is one by one:
the previous series of articles mentioned a common mode used in CS2-proxy mode, I will not elaborate on the many advantages of the proxy mode here. The most prominent thing is that you can use a third-party organization in your own rules instead of relying on a third-party organization directly. When the formation of a third party changes, you only need to change the proxy layer. Similarly, this mode is also used when CS2 processes memberrole. Let's take a look at what this mode brings.
let's take a look at the communityservercomponents project, which is the core of CS and defines the abstract classes, interfaces, public methods, and entity classes required for running CS, obviously, the interface for defining memberrole should also be defined here, which also complies with the interface inversion principle. The user-defined interface of the interface is not the provider. Open the \ Components \ provider \ User \ folder in the project. The folder contains the definition and calling rules of all interfaces:

Call all the interface definitions created by memberrole. It can be seen that except for the entity method of the abstract class memberroleprofileprovider, all others are defined for the interface. The object method in memberroleprofileprovider is called, the method here tells us to find the proxy to be loaded through configuration and load it in due time: Static Memberroleprofileprovider ()
{

Csconfiguration config = Csconfiguration. getconfig ();
Provider provider = Config. Providers [ " Memberroleprofileprovider " ] As Provider;
If (Provider ! =   Null )
{
If (Globals. isnullorempty (provider. Type ))
Throw   New Exception ( " Memberuserroleprovider found, but no type attribute was specified " );

Type type = Type. GetType (provider. type );
If (Type =   Null )
Throw   New Exception ( String . Format ( " Memberuserroleprovider type {0} cocould not be loaded " , Provider. Type ));

Murp= Activator. createinstance (type) As Memberroleprofileprovider;
If (Murp =   Null )
Throw   New Exception ( " Memberuserroleprovider cocould not be loaded from the type "   + Provider. type );
}
}

This static method is used to complete this task.
Configure the memberroleprofileprovider of providers on the node in communityserver. config, which tells CS2 which proxy to use to process memberrole. < Add
Name = "Memberroleprofileprovider"
Type = "Communityserver. memberrole. csmemberroleprofileprovider, communityserver. memberrole"
/>

Now, after reading the interfaces, we can easily guess what the proxy layer should do. Of course, these interfaces are implemented:


We can see that CS2 has two memberrole proxy layers, one for memberrole1 and the other for ASP. for the memberrole of net2.0, you can select one of the two components. Fill in the agent of the corresponding component in the configuration file. Program Set (that is, the displayed project) is OK, because they have correctly implemented the CS-defined interface. Note that CS2 uses memberrole1.0 by default, if ASP is required. memberrole in net2.0 also needs to run the SQL script in the project to upgrade the database. Now let's take a look at communityserver. memberrole, which implements the proxy layer of memberrole1.0:


Here we can see that csroles, csprofiles, and csmembership are referenced only in the main csmemberroleprofileprovider. How do we know the rest of the implementations of memberrole. config to open the web. in the config file, we can see that the configsections node has the following Configuration: < Sectiongroup Name = "Memberrolesprototype" >
< Section Name = "Membership" Type = "Microsoft. scalablehosting. configuration. membershipconfighandler, memberrole, version = 1.0.0.0, culture = neutral, publickeytoken = b7c773fb1_e7ken"   />
< Section Name = "Rolemanager" Type = "Microsoft. scalablehosting. configuration. rolesconfighandler, memberrole, version = 1.0.0.0, culture = neutral, publickeytoken = b7c773fb1_e7ken"   />
< Section Name = "Profile" Type = "Microsoft. scalablehosting. configuration. profileconfighandler, memberrole, version = 1.0.0.0, culture = neutral, publickeytoken = b7c773fb1_e7ken"   />
< Section Name = "Anonymousidentification" Type = "Microsoft. scalablehosting. configuration. anonymousidconfighandler, memberrole, version = 1.0.0.0, culture = neutral, publickeytoken = b7c773fb1_e7ken"   />
</ Sectiongroup >

There are also
< Providers >
< Add Name = "Communityserversqlprovider" Type = "Communityserver. memberrole. csprofileprovider, communityserver. memberrole" Connectionstringname = "Sitesqlserver" Applicationname = "Dev" Description = "Stores and retrieves profile data from the local Microsoft SQL Server database"   />
</ Providers >

This tells the system how to call memberrole.
by configuring the above items, You can implement basic user management in the system, of course, we will see that CS2 has done a lot of work while dealing with user management. This is not something that can be discussed clearly at half past one. Here, we should give a brick first, more advanced applications require your understanding.

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.