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.

  • Does your feature use RunWithElevatedPrivileges at all? How are you getting the current user object? – TZHX Dec 5 '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 5 '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 5 '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 5 '12 at 11:24
  • Also - I've set file.Item["Created By"] aswell, but the problem still persists. – JᴀʏMᴇᴇ Dec 5 '12 at 11:26

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

|improve this answer|||||

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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.