1

We are creating and updating items in the sitecore tree, we are using SecurityDisabler to perform the operation. The system considers the operation is performed by an anonymous user but we need to log the user.
Can you suggest which Sitecore API we need to use so that we can pass a user identity?
our objective is to track changes whether it is from the content author or any program.

2 Answers 2

5

From what I know, you cannot do this if you're using SecurityDisabler.

If you use SecurityDisabler Sitecore doesn't save the information who made the change.

You should do your changes in UserSwitcher context:

using (new UserSwitcher(username, isAuthenticated))
{
    // your code here
}

If you do this, Sitecore will check access rights for that particular user. So you must be sure user has access rights to edit that item.

5

We have two options to edit/create a sitecore items using sitecore API

  1. SecurityDisabler - It is not recommended for your approach/requirement because SecurityDisabler will grant user with administrative access. So the contextUser can do any thing.
  2. UserSwitcher - It allows a segment of code to run under a specific user instead of current context user.

Here are small code sample with snapshot along with output

Before code reach UserSwitch

enter image description here

After code reach UserSwitch

enter image description here

Referred from this link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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