Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can use the regular ASP.NET membership functions to create and manage users. Look inside N2.Edit.Membership.Edit and you will find that it is as simple as: 

To do this...Use this code...
Add a user to a role
Roles.AddUserToRole(username, rolename); 
Remove a user from a role
Roles.RemoveUserFromRole(username, rolename);
Save changes to a user
System.Web.Security.Membership.UpdateUser(username);
Create a new user 
Delete a user 

How does it work?

If you look in web.config you will see that everything membership-related is actually driven by N2.Security.ContentMembershipProvider by default. 

Code Block
languagehtml/xml
<providers>
	<add passwordFormat="Hashed" 
		name="ContentMembershipProvider" 
		type="N2.Security.ContentMembershipProvider, N2.Management" />
</providers>

This in turn uses something called ItemBridge to persist the standard .NET Membership objects as regular ContentItems. 

Extending the N2CMS User Profile

First, define class with your custom profile extension, inheriting N2 User.

...