0

I have implemented a feature in my solution where by the current user's Name is assigned to a field. With certain users - this appears as 'System Account'. Is it possible that if somebody is the site collection admin., for example, this will happen? I can't work out why.

JᴀʏMᴇᴇ
  • 1,071
  • 2
  • 19
  • 48
  • Does your feature use RunWithElevatedPrivileges at all? How are you getting the current user object? – TZHX Dec 05 '12 at 11:03
  • @TZHX - I am indeed. I've just done some reading around and now appreciate that using elevate privleges to update an item sets it as modified by and authored by the system account. I need both to be the current user. – JᴀʏMᴇᴇ Dec 05 '12 at 11:20
  • Indeed. It's a common problem. What sort of context is the code running in (EventReceiver, etc.)? Some make it easier to work around than others. – TZHX Dec 05 '12 at 11:23
  • It's all functionality that supports a customised 'document upload' feature. I'm successfully setting file.Item["Author"] and file.Item["Modified By"] but for some reason (when retrieving the newly uploaded document) File.Item.Author is still System Account!? Thanks a lot for your reply. – JᴀʏMᴇᴇ Dec 05 '12 at 11:24
  • Also - I've set file.Item["Created By"] aswell, but the problem still persists. – JᴀʏMᴇᴇ Dec 05 '12 at 11:26
  • You should post the code for your method. – TZHX Dec 05 '12 at 12:20

2 Answers2

1

CHeck the Central admin and go to Web application and see the user policy from ribbon and see if some account is added as to be run under system account

Geek
  • 545
  • 1
  • 13
  • 29
0

Trying using properties.UserLoginName rather than geting the user name from the context objects (as the context is running under elevated credentials).

TZHX
  • 1,062
  • 7
  • 19