c# - ASP.NET Implementing "Act As" functionality when using Windows Authentication and Custom Role Provider -
i'm trying implement "act as" functionality asp.net application while @ same time using windows authentication , custom role provider. want able is:
- use windows auth current user's domain account verify approved domain user
- use custom role provider permission information sql server database.
- implement functionality allow admins of application able "act as" user, without requiring them log application user.
the scenario i'm trying fulfill application admin attempting assist user problem , clicks "act as" button act user , see application see it. role provider need understand current user acting else , permissions information user instead of current user.
my plan implement impersonation feature delete roles cookie , add value session variable indicating user impersonating user. session not populated @ time authorization occurs however, isn't possible. don't want use cookies don't want cause potentially persistent state on admins machine (such admin couldn't open window app , either act user or view own data).
i can't find way (without cookies) save "acting user..." information given session unavailable. i'd use role provider, etc., can leverage built in security trimming in .net. may impossible, i'm hoping out there has either tried before or has suggestion can attempt implement.
thanks in advance!!
see answer similar question here
the gist of is:
the way did this, admittedly little crude, have impersonation table in database contains logon name of user doing impersonating , logon of user wish impersonate.
i added override code when user first goes page (it uses windows authentication), check see if user has impersonation set in table , place user id in object in session state. if there no impersonation, place actual user id in same object.
to prevent me doing things user's data them, there 2 properties in object, 1 logon_name, used system content-customization, , called nameforlog, used when logging actions. actions make logged me.
all areas on site display user-customized content @ session object, use impersonated id , therefore show me user seeing. beyond first page , logging code, doesn't know me dealing with.
for scenario, implement roles provider , override getrolesforuser return roles impersonated user plus role allow impersonating user access impersonation functionality purposes of turning off.
you return impersonated user's roles impersonating user's roles in order give admin user access of own features user impersonating, depends how affect usefulness of feature in particular scenario.
Comments
Post a Comment