Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adriano Fabri 383 posts 1280 karma points
    Apr 08, 2010 @ 13:50
    Adriano Fabri
    0

    Problems to retrieve the current user logged into Backend

    Hi to all,
    I have a problem to retrieve the logged user details.

    I'm doing a tool to delete a user.

    First of all I want to check if the logged user is an Administrator

    protected void Page_Load(object sender, EventArgs e)
            {
                User userCurrent = User.GetCurrent();

                if (userCurrent.UserType.Name == "Administrators")
                {
                    btnShowUsers.Visible = true;
                    ltrlDescription.Visible = true;
                }
                else
                {
                    ltrlDescription.Text += "<span style='color: #FF0000; font-weight: bold;'>WARNING: You are logged as '" + userCurrent.UserType.Name + "'<br /><br />Only the 'Administrators' can delete a user<br /><br />Please login with an administrative account</span>";
                    ltrlDescription.Visible = true;
                }
            }

    And now the problem...

    I created an editor account to test if the function run properly.
    Now I logout as admin and login as editor
    Result: userCurrent.Name = admin instead of editor.

    I tried also with the UmbracoEnsuredPage.CurrentUser but I have the same problem.

    I think this is a session problem but I don't know how can I refresh it.

    Can anybody help me?

    I'm using Umbraco 4.0.2.1 (.Net 2.0)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies