How to identify if a user is a MCMS administrator?

Chester needs to get the credits for the findings in the following blog as he pointed me to this specific behaviour!

MCMS does not have a documented method to identify if the current user is a MCMS administrator or not. But there is a very easy way around this if you are using the CmsHttpContext!

The CmsHttpContext has a UserCacheKey property which is used by ASP.NET output caching with MCMS in combination with the VaryByCustom=”cmsrole” method to ensure that content can be varied for different user roles.

The MCMS help gives the following statement for this property:

UserCacheKey is guaranteed to be the same for two users, of those two users are both members of all the same MCMS rights groups. UserCacheKey will also be the same for two users if both users are MCMS administrators. In contrast, UserCacheKey is different for two users if those two users do not meet either of the above two requirements.

Looking at the value returned for this property for MCMS administrators shows that always “A” is returned!

So a simple check for this property for the string “A” is sufficient to identify if the current user is a MCMS administrator or not!

Actually there is no guarantee that this property value will be the same with the next service pack. But the chance that this gets changed is very low.

8 Comments


  1. Hi Stefan

    Is there a way to Export and Import just user group rights and users from Site Manager in MCMS 2002?

    Reply

  2. Hi Ankit,

    no, this can only be done using the Site Deployment API.

    Cheers,

    Stefan

    Reply

  3. Can you give me an example how to do it using Site Deployment API’s ? I have an existing MCMS Database which has more then 100 users and 50 User groups I need to Import all new SDO to it how do I retain the user groups and right there so that channel hierarchy is new but rights are old.

    Reply

  4. Hi Ankit,

    the following script can be used to export all users and rights groups:

    Dim pCmsDeployExport

    Dim shell

    Dim pExportOptions

    Set pCmsUserGroupBackupRestore =

    CreateObject("CmsDeployServer.CmsUserGroupBackupRestore.1")

    pCmsUserGroupBackupRestore.AuthenticateAsCurrentUser()

    If ( Err.Number <> 0 ) Then

    Call MsgBox(Err.Description, vbCritical, "Backup/Restore PROBLEM")

    Set pCmsUserGroupBackupRestore = Nothing

    else

    strPackageFileName = "c:export-users.sdo"

    strReportUrl = pCmsUserGroupBackupRestore.Backup("strPackageFileName")

    ‘ Display the report in the Web browser.

    Set shell = WScript.CreateObject("WScript.Shell")

    shell.Run "http://localhost&quot; & strReportUrl, 7

    WScript.Echo "Export complete."

    end if

    Cheers,

    Stefan

    Reply

  5. Thank Stefan, It worked for me 🙂

    Reply

  6. Just checked it did imported the users but the Channel rights were not imported, while Importing the SDO I chose:

    Use Package Container Rights in Containers

    Replace with package container rights

    I dont know what am I doing wrong it is importing all the users and groups but not the Channel/Resource/Template rights, can you tell me why please.

    Reply

  7. Hi Ankit,

    that is as expected. This CmsUserGroupBackupRestore allows to backup/restore rights groups with users. To deploy rights on the channels you need to export the channels with the appropriate option in Site Manager. There is a "Rights Options" tab on the Site Deployment export dialog and there are options on whether to import container rights on the import dialog.

    Cheers,

    Stefan

    Reply

Leave a Reply to Ankit Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.