Microsoft Professional

Sunday, February 05, 2006

Create Resource Gallery Programmatically(MCMS)

Publishing API cannot create Resource Galleries. To solve this problem you can use ASP file called resstub.asp. This file is used bt Site Manager and can do many things which can't be done by CMS APIs (for example create resource gallery). This file depend on transferring requestes using XML. These XMLs has some parameters depend on versions of MCMS (internalClientVersion, clientVersion, clientVersionNumber).

Steps to use this file:

  1. Create c# Project
  2. Add AEServerObject.dll and AEStubObject.dll as references
  3. Use Code Below:
    // {0} = CMSAUTHTOKEN value
    // {1} = GUID of Parent Resource Gallery
    // {2} = Name of new Resource Gallery
    private const string requestCreate = "";
    // {0} = CMSAUTHTOKEN value
    // {1} = GUID of new Resource Gallery
    private const string requestCommit = "";
    /// The main entry point for the application.

    static void Main(string[] args) {
    session.Login("WinNT://DOMAIN/username", "password", "localhost", 0);
    string rootGuid = null;
    AESERVEROBJECTLib.IAEServer server = session.GetDefaultServer();
    foreach(string s in server.Children)
    AESERVEROBJECTLib.IAENode n = server.GetNodeByGUID(s, false);
    if(n.Name == "Resources") { rootGuid = s; break; } }

    string newGuid = CreateResourceGallery(session, "resource1", parentGuid);
    // COMMIT session.CommitAll();
    static string CreateResourceGallery(AESERVEROBJECTLib.AESessionClass session, string newName, string parentGuid)
    AEStubClass stub = new AEStubClass();
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(stub.ProcessRequest((AESTUBOBJECTLib.IAESession6)session, "", String.Format(requestCreate, session.LoginCookie, parentGuid, newName)));
    string newGuid = doc.DocumentElement.SelectSingleNode("
    stub.ProcessRequest((AESTUBOBJECTLib.IAESession6)session, "", String.Format(requestCommit, session.LoginCookie, newGuid, newName)); return newGuid;

1. To run sample below you need to adjust these parameters (internalClientVersion, clientVersion, clientVersionNumber) depending on you MCMS version.
2. To Use this file to do many action like sample code. you need to trace foramt of passed XML between Site manager and resstub.asp. Easy way to do that change file resstub.asp to save requests from Site Manager.


  • Ouch, Stefan is not a fan of your article (
    While your code tries to address a glaring hole in the API, most MCMS users cannot afford to be in an unsupported configuration.

    By Blogger Christopher Bermingham, at 6:19 AM  

  • Stefan's comment makes me wonder whether the 'freedom to innovate' movement was aborted with two billion payed to Sun Microsystems.

    Did that money purchase Microsoft the license to not allow innovation by others on its products (like adding delegates to java).

    By Blogger Chicken Little, at 7:47 PM  

  • internet business opportunitiesinternet business opportunitiesBuy one of our Directory Websites contact us at for full details.

    internet business opportunities Title: 25000 pages of quality articles coverng wide range of subjec
    Section: Education
    Description: Article Directory - Over 25500 articles available to view
    Submitted by: Tony
    Submission details at the end of this message

    internet business opportunities

    By Blogger Barnsley-Freeads, at 7:30 PM  

  • Stefan did the right thing when he raised the support issue.

    you should add an update to your article that clearly states that this is an unsupported way of using the API and it will result in an unsupported configuration.


    By Blogger Stephen Cawood, at 7:45 PM  

  • Hello.

    First of all, excuse my bad English.

    Sorry, but I'm triying to play this exemple, but don't work.

    I have a W2003 Server and MCMS2002 and I create a WinForm (in C#), and just put the code of you exemple.

    The first part run correctly, but in the "doc.LoadXml(strXML)" I get an error. I separate de inside intruction to an after variables called strXML (string strXML = stub.ProcessRequest((AESTUBOBJECTLib.IAESession6)session, "localhost", String.Format(requestCreate, session.LoginCookie, parentGuid, newName));).

    Can anyone helpme?

    Thank You Very Much!

    By Anonymous Anonymous, at 2:46 AM  

Post a Comment

Links to this post:

Create a Link

<< Home