We are writing a Storage Extension. In the Storage extension is it possible to fetch the identity of the user who published the item?

I need the user name because I am creating an application which will be scheduling the publishing of an item by impersonation. There are some items for which records will be inserted by storage extension in MySQL database. In that record I need a column which can tell me the username of each publishing transaction.

If yes can you please share some sample code?

Issue is resolved:- Solution refer

  • Why you would you need a user in a Storage Extension, what is your plan with it? (please update the question with more information, so answers can be given in that direction) Commented Jul 30, 2013 at 11:03
  • I have updated the question.
    – AlokBhatt
    Commented Jul 31, 2013 at 5:25

2 Answers 2


Your description is still a little bit too abstract to determine whether a storage extension is the best place to handle this- could you be a little bit more specific about why it is you want to do this.

There is user information available on the content delivery side, however this is not necessarily the user who published the item. If you look in the ITEMS table in the broker database, you will see a TRUSTEE column which contains the username (not ID) of the user who last edited the item. If you look at a transport package you can also find this information in the xml file for the item(s) published. For example for a component, in components.xml:

  <Component Id="tcm:9-99" isMultimedia="false">
      <Title>My Component</Title>
      <Schema Id="tcm:9-95-8" />
      <OwningPublication Id="tcm:0-4-1" />

So I guess you can access this information from within a storage/deployer extension.

If you really need the user who published the transaction, Version 2013+ contains an update whereby you can, from templates access the user who published via Engine.PublishContext.RenderContext.PublishTransaction.Creator. Note that this is not applicable for 2011 and earlier versions, where its a bit harder to get the Publish Transaction

So one thing you could do is add a binary on the fly into the publish transaction which is an xml file containing user id and whatever other details you want to store. Give it a suitably unique file extension (like .ptinfo or something) and then create a Item mapping for this file extension in your storage conf and a storage extension to put it in your MySQL database. The following gives some (untested) TBB code to do this...

public class AddTransactionInfo : ITemplate
    public void Transform(Engine engine, Package package)
        var renderContext = engine.PublishingContext.RenderContext;
        //Context variables have scope of the whole transaction, so we can use them
        //to ensure we only generate the binary once per transaction.
        if (renderContext != null && !renderContext.ContextVariables.Contains("PublishTransactionInfo"))
            var pubTransaction = renderContext.PublishTransaction;
            //Create an XML binary stream with the user id
            XDocument infoXml = XDocument.Parse("<transaction/>");
            MemoryStream binaryStream = new MemoryStream();
            infoXml.Root.SetAttributeValue("userid", pubTransaction.Creator.Id.ItemId);
            //Add the binary with unique filename and special file extension
            engine.PublishingContext.RenderedItem.AddBinary(binaryStream, pubTransaction.Id.ItemId + ".ptinfo", "ptinfo", "text/xml");
            //Set the context variable to prevent repeating this process
            renderContext.ContextVariables.Add("PublishTransactionInfo", infoXml);
  • Your suggestion of publishing an xml file on the fly seems a good option for me. Can you please provide some link or information so that I can try this.
    – AlokBhatt
    Commented Aug 8, 2013 at 10:04
  • I added some example TBB code to generate the XML once per transaction...
    – Will Price
    Commented Aug 8, 2013 at 12:20
  • 1
    This is in the right general direction, but maybe it would be better to use RenderedItem.AddMetadata() Commented Aug 8, 2013 at 13:07
  • Dominic - does that metadata persist over all items in the publish transaction? So if I publish a SG, will it be there for all pages?
    – Will Price
    Commented Aug 8, 2013 at 13:53
  • If you add RenderedItem.AddMetadata() in a page TBB it should make metadata available for each page in the transaction, but it doesnt store that added metadata in the broker afaik.
    – Raimond
    Commented Aug 8, 2013 at 14:13

The Storage Extension is executed on the Content Delivery side, so there is no concept of a user there available anymore (users are only on the Content Manager side, further down all actions are being handled by service and/or admin user accounts).

I believe that you don't even have access to the Publish Transaction ID inside the Storage Extension anymore, since that also isn't considered relevant on that level anymore. But technically the user who did the actual rendering and transporting of the package, is the SDL Tridion System Administrator, the user you are probably looking for is only the one who queued the Publish Transaction.

So in short, the user is not available.

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.