0

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?

ria
  • 819
  • 5
  • 19
  • 40

2 Answers2

1

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
  • 3,284
  • 1
  • 15
  • 18
  • will it be different than the way above mentioned?? if yes, why will it be different? – ria Feb 23 '10 at 17:42
  • Yes. WindowsIdentity.GetCurrent() will always return the Process identity (i.e. NETWORK SERVICE) – zincorp Feb 23 '10 at 18:12
  • 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 Feb 24 '10 at 05:51
0

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

Phill Duffy
  • 2,805
  • 3
  • 33
  • 45
  • actually the application pool account is a user called xyz\myusername where xyz is my domain and myusername is the windows account...still the workflow shows current user as the network service – ria Feb 23 '10 at 17:34