Assigning role to user programmatically can easily be done using DotNetNuke's RoleController in your code. It means without storing role info in database, and programmatically assign a role rights to the user. You can call AddUserRole function in RoleController to perform this action the below code might help you in achieving this
RoleController objRoles = new RoleController(); RoleInfo objRole = new RoleInfo; // autoassign user to portal roles var arrRoles = objRoles.GetPortalRoles(user.PortalID); foreach (var obJrole in arrRoles) { if (objRole.AutoAssignment == true) { objRoles.AddUserRole(user.PortalID, user.UserID, objRole.RoleID, Null.NullDate, Null.NullDate); } } objRoles.AddUserRole(user.PortalID, user.UserID, 5, Null.NullDate, Null.NullDate);
/Adnan
This post is from my old blog posted on May 2012, that unfortunately no longer exist.
0 comments :
Post a Comment