Method
private void DeleteUserRoleByName(string username, string roleName)
{
//Get Current Dnn Portal ID
var portalID =
DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId;
//Initialize RoleController
var rc = new DotNetNuke.Security.Roles.RoleController();
//Retrieve role
var ri = rc.GetRoleByName(portalID, roleName);
// Delete User role
rc.DeleteUserRole(
portalID,
DotNetNuke.Entities.Users.UserController.GetUserByName(portalID, username).UserID, ri.RoleID );
}
Usage
DeleteUserRoleByName("username", "rolename");
No comments:
Post a Comment