Portal Engine
Version 3.x > Portal Engine > How can I programatically remove user form the role View modes: 
User avatar
Member
Member
Tomasz kosinski - 10/3/2008 6:18:41 AM
   
How can I programatically remove user form the role
Upon custom authentication I use code:

// Assign user to the current site
usr.SitesRoles[siteName.ToLower()] = rolesTable;

// Add new role "external role" and assign it to the user
rolesTable["DownloadAccess"] = 0;

It adds role "Samples" and user to this role. This membership seems to be permanent. How can I programmatically remove the user from the role "DownloadAccess"?

I need it to remove user-role aasignment for example because rule in exteranl database has been changed (like expierd support etc)

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 10/3/2008 8:17:47 AM
   
RE:How can I programatically remove user form the role
Hi,

“This membership seems to be permanent.” – do you mean permanent in one session or always?

This assignment is done after every log in, so if you would like not to assign to this role after next log in, you could simply remove the line:

rolesTable["DownloadAccess"] = 0;

and after next log in, the user would be not assigned to any roles.

If you mean removing in one authentication session, you could use for example this code:

Hashtable rolesTable2 = new Hashtable();
string siteName = CMSContext.CurrentSite.SiteName;
usr.SitesRoles[siteName.ToLower()] = rolesTable2;

- it assigns no role to user.

If you mean something else, please let us know.

Best regards,
Helena Grulichova