all groups > dotnet security > july 2004 >
You're in the

dotnet security

group:

sharepoint - impersonating the authenticated user.


sharepoint - impersonating the authenticated user. Tamim Sadikli
7/15/2004 2:14:02 AM
dotnet security:
Under IIS 6.0, ASP.NET Web applications run inside the ASP.NET Worker Process (aspnet_wp.exe).

When the ASP.NET Worker Process starts a Web application, the Web application inherits the identity of this worker process (Network Service by default), or if impersonation is enabled, the Web application runs under the user account that is authenticated by IIS, or the user account that is configured in the Web.config file. Fine.

A document event handler however isn't a web application, it is a class library used by a web application, (which can be identified within the MSSharePointPortalAppPool application pool). Consequently the authenticated token doesn't get passed to it, and it runs under the application pool identity instead.

Impersonation is still possible within the event handler, but it has to be explicitly legislated for at a code-level, by invoking the (unmanaged) LogonUser(). Implementation of this strategy for a specified user is well documented, both within MSDN and outside, but I have found no documentation on how to get hold of the impersonated/authenticated token WITHIN THE EVENT HANDLER ITSELF.

One workaround that i have played with is to use SSO to take the user to the SSO logon form the first time the event is triggered, but the call to GetCredentialEntryUrl() fails. Can it only be called from within a web part? If not, is there another way to retrieve the authenticated token from within the event handler?
Re: sharepoint - impersonating the authenticated user. Brad Smith [MVP]
7/19/2004 5:03:25 PM
There is not. The token is destroyed by the time the event assembly thread
spins up
Just wondering, why do you need to run the event assembly in the user
context? You should have access to anything you may need since it runs in
the context of the Sharepoint admin account.

-Brad

[quoted text, click to view]
application inherits the identity of this worker process (Network Service by
default), or if impersonation is enabled, the Web application runs under the
user account that is authenticated by IIS, or the user account that is
configured in the Web.config file. Fine.
[quoted text, click to view]
library used by a web application, (which can be identified within the
MSSharePointPortalAppPool application pool). Consequently the authenticated
token doesn't get passed to it, and it runs under the application pool
identity instead.
[quoted text, click to view]
explicitly legislated for at a code-level, by invoking the (unmanaged)
LogonUser(). Implementation of this strategy for a specified user is well
documented, both within MSDN and outside, but I have found no documentation
on how to get hold of the impersonated/authenticated token WITHIN THE EVENT
HANDLER ITSELF.
[quoted text, click to view]
the SSO logon form the first time the event is triggered, but the call to
GetCredentialEntryUrl() fails. Can it only be called from within a web part?
If not, is there another way to retrieve the authenticated token from within
the event handler?
[quoted text, click to view]

Re: sharepoint - impersonating the authenticated user. Tamim Sadikli
7/20/2004 9:57:03 AM
Hi Brad,

You asked: 'why do you need to run the event assembly in the user
[quoted text, click to view]

A) I've written a document event handler to move documents around within a document library, based on the value which a particular property (e.g. DestFolder) is set to. It works just fine. However because it runs in the context of the application pool identity, the 'Modified By' field is set to this account once the document has moved folders, and I want it to be set to the UserName of the user who caused the move, i.e. who set the doc. property - i.e. the authenticated user.

SSO was a dead-end because I'm dealing with a sharepoint site, not a portal site. If you could suggest an alternative that would be wonderful.

Tamim.


[quoted text, click to view]
Re: sharepoint - impersonating the authenticated user. Brad Smith [MVP]
7/20/2004 3:48:42 PM
I would suggest trying to assign the Modified By field in the assebly to the
user information that is passed with the event. It may be read-only, I know
some of the meta fields are, but you should give it a shot. If that doesn't
work, create new Modified By field and do the assignment manually on every
event.

-Brad

[quoted text, click to view]
document library, based on the value which a particular property (e.g.
DestFolder) is set to. It works just fine. However because it runs in the
context of the application pool identity, the 'Modified By' field is set to
this account once the document has moved folders, and I want it to be set to
the UserName of the user who caused the move, i.e. who set the doc.
property - i.e. the authenticated user.
[quoted text, click to view]

AddThis Social Bookmark Button