When a component is published successfully, we want a related component to be auto published (am not going into the details of why we need this). We are trying to implement this through event system.

this.EventSystem.SubscribeAsync<Component, SetPublishStateEventArgs>(this.OnComponentSetPublishState, EventPhases.Initiated);

Though the related component is added to the queue, it is added to the queue by system user ""Tridion Content Manager System NT Authority User", not by the user who actually published the first component. Is there a way by which we can have the related component added to the publishing queue by the actual user? Version: SDL WEB 8.5

3 Answers 3


Publish transaction gets created by the user, but the actual publishing happens in the Publisher service under the system account (the one that runs the Windows service). That account is used (among other tasks) to set publish states on published items. In order to send another item to publish on behalf of the original user, you need to create a new Session using the username of the original user and create new PublishTransaction using the new session.

Make sure the System NT Authority User is configured to be impersonation user.

  • Thank you for your suggestion. We have tried to impersonate session with user who initiated the publish transaction for the related items. But still it is published with system user account only. We have tried this approach in Event system as well as from our templating code. this.EventSystem.Subscribe<Component, SetPublishStateEventArgs>(this.OnComponentSetPublishState, EventPhases.Initiated) var session = new Session(e.Publisher.Title); var targetTypes = e.Target.TargetTypes; var publishInstruction = new PublishInstruction(session); // code to pubish
    – Nithya
    Commented Aug 29, 2019 at 13:22
  • @Nithya, could you please share the full code of the event handler?
    – AntonM
    Commented Aug 30, 2019 at 10:06
  • Shared the code as an answer to retain the formatting.
    – Nithya
    Commented Aug 30, 2019 at 18:01
  • your code has helped to solve the issue. Thank you very much.
    – Nithya
    Commented Sep 2, 2019 at 18:57

In order to use Impersonation, I guess you would need to add all the users that may publish this content type as an impersonation user in Tridion Impersonation Users.

IIRC you also have to allow a change to the Local Security Policy to bypass traverse checking.

I would suggest one of two other options

  1. You could elevate the user during the event and publish the target Component
  2. You could keep a field (and therefore easily seen in component history) by updating the target component and then publishing it {of course - it's not clear if you've a 1:1 relationship of *:1 with the target Component being published many times}

The reason I add 2 is that I saw a similar requirement some time ago and we had to take account of the fact that:

  • the publish queue is trimmed and republishing that component to the same target will overwrite the previous instance {i.e. you only know who published it last}
  • there was no scope to write a fancy publish tracking system
  • the audit team had access to content but didn't have/want access to publishing data directly anyway {the published by/on was field that lived with the historical versions of that Component and was easy to see was version of content was published by whom at a specific point in time}
  • Thank you for your suggestion. Still the related components are published with system user account.
    – Nithya
    Commented Aug 29, 2019 at 13:30
  • Still the related components are published with system user account. using (ElevatedPrivilegesScope scope = new ElevatedPrivilegesScope(subject.Session, Privileges.SysAdmin)) { var session = new Session(e.Publisher.Title); var targetTypes = e.Target.TargetTypes; var publishInstruction = new PublishInstruction(session); } Skeptical about elevating user privilege as no action need to be performed with related items.Tried publish related components with same user id when base components is published.
    – Nithya
    Commented Aug 29, 2019 at 13:42
  • In that case perhaps you have to impersonate the user? This isn't something we've tried as we ruled out faking who/what publishes and Audit preferred a true account so we used matadata to track Commented Aug 29, 2019 at 17:53
this.EventSystem.Subscribe<Component, SetPublishStateEventArgs>(this.OnComponentSetPublishState, EventPhases.Initiated);
    private void OnComponentSetPublishState(Component subject, SetPublishStateEventArgs e, EventPhases phase)
        var publishInstruction = new PublishInstruction(subject.Session);
        var targetTypes = e.Target.TargetTypes;
        PublishEngine.Publish(new[] { subject.Session.GetObject("tcm:882-1053226") as Component }, publishInstruction,
  • Try to create a new session and use it in the event handler like this: using (var userSession = new Session(e.Publisher.Title)) { var publishInstruction = new PublishInstruction(userSession); var targetTypes = e.Target.TargetTypes.Select(tt => (TargetType) userSession.GetObject(tt.Id)).ToList(); PublishEngine.Publish(new[] { userSession.GetObject("tcm:882-1053226") as Component }, publishInstruction, targetTypes); }
    – AntonM
    Commented Sep 2, 2019 at 6:19

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.