views:

43

answers:

2

I am using the following code

    WindowsIdentity wIdb4 = WindowsIdentity.GetCurrent();
    string name = wIdb4.Name;

in a workflow to show which user account is being used to upload a document. When i write the above mentioned string in a workflow history event, it always returns NETWORK SERVICE, even if i am logged in using the site collection administrator. Can anyone tell me why is this so?

+1  A: 

Try using:

SPContext.Current.Web.CurrentUser.Name

EDIT:

I figured there may not be an associated SPContext in your workflow.

What does he following resolve to within your workflow?

workflowProperties.OriginatorUser
zincorp
will it be different than the way above mentioned?? if yes, why will it be different?
ria
Yes. WindowsIdentity.GetCurrent() will always return the Process identity (i.e. NETWORK SERVICE)
zincorp
strange enough ... on my dev machine i get a NullReference exception on using SPCOntext.Current ... When i debug it says SPContext.Current is null...can you tell me why is this so?
ria
A: 

Workflow will always run as a service account (typically the IIS Application Pool account)

Phill Duffy
actually the application pool account is a user called xyz\myusernamewhere xyz is my domain and myusername is the windows account...still the workflow shows current user as the network service
ria