I am familiar with impersonating an account in .net with:
dim myIdentity as WindowsIdentity = someIdentity
using ctx as WindowsImpersonationContext = myIdentity.Impersonate()
doStuff()
end using
Is it possible to define a .net attribute so that I can write something like:
< runAsUser(someIdentity) > public sub doStuff()
and then when using the method doStuff()?
Update
Okay, I was told that this might not be possible, because the arguments to the attribute constructor should be constants that would preclude passing in the user ID.
Let me ask the question a little differently: Suppose that there is a function getUserWindowsIdentity()that returns the identifier associated with the registered user.
< runAsLoggedInUser) > public sub doStuff() >, , getUserWindowsIdentity doStuff()?