Hi,
I have some trouble understanding and implementing impersonation from code
in a WSS webpart.
It quite well documented in the WSS SDK how to use impersonation when
writing document library event handlers. It works ok.
But how can impersonation by used from code within a webpart ?
This is my situation:
The content of a webpart needs to depend on the current user. The code
checks wether the user is in a certain (custom) role and shows more or less
content depending on the role. There is no problem when the current user is
allowed to check the membership of roles, but when the current user is only
a reader, a logon box appears because the code cannot be executed with the
current users permissions. (in the web.config, identity impersonation =
true)
I thought using impersonation from code for that bit of code would help:
... impersonate with account that has permissions
... execute code
... undo impersonation
However, the result is the same. I'm sure the impersonationcode is ok, I get
a token etc. but SharePoint does not seem to take over the credentials. I
don't no if impersonation from code is possible when identity impersonation
is set to true.
Any ideas ?
Jeroen db