Copied to clipboard

Flag this post as spam?

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


  • Jed 55 posts 80 karma points
    Apr 11, 2011 @ 18:46
    Jed
    0

    Authentication - write logged in users name

    I've spent four days trying to get Umbraco to write the logged in username to screen in an Intranet environment. There seems to be no clear process defined anywhere, just random pointers that lead nowhere. It shouldn't be this difficult - so where can I find i) the code to write, and ii) where to put it, so I can see the logged in user's name?

    Thanks

  • Ernst Utvik 123 posts 235 karma points
    Apr 11, 2011 @ 19:20
    Ernst Utvik
    1

    In a .xslt file in the developer section of Umbraco you can get the current logged in users name with this code:

    <xsl:value-of select="umbraco.library:GetCurrentMember()/@nodeName"/>

    If you have a custom property in your member type that you want to display, you can switch @nodeName with your custom property alias. To display username you can use @loginName

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 11, 2011 @ 19:49
    Jan Skovgaard
    0

    Hi Jed

    If you're familiar with XSLT you should give Ernst's suggestion a go.

    How have you tried to get the name to display?

    And are you keeping members in the member section in Umbraco or do you hook up on another system? Umbraco is based on the standard ASP.NET membership provider but you should be able to use your own.

    What version of Umbraco are you working with?

    /Jan

  • Jed 55 posts 80 karma points
    Apr 12, 2011 @ 13:37
    Jed
    0

    Hello Jan/Ernst. Thanks for your help. When I use GetCurrentMember as suggested I get nothing returned. I aim to use Umbraco for our Intranet. If staff are on our LAN I'd like them to be able to access without logging in (they've logged in to our LAN, so we should use their windows login credentials) and if they're outside our LAN they fill in a form. Either way, once they're in Umbraco should be able to see their username/group/anthing that can give me something to present restricted content to different members.

    I keep reading snippets about membership providers and ASP.NET authentication that suggests it's all very simple, but it most certainly isn't because after many days of struggling with it I'm no closer to a solution. It's hard to justify spending this much time on such an apparently easy operation. All I need to know is:

    1) The approprate IIS Authentication/Authorization settings

    2) Any code to display a username or to define who's logged in, and where to put that code.

    I'm using Umbraco 4.6.1

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Apr 12, 2011 @ 14:10
    Michael Latouche
    0

    Hi Jed,

    In your case I guess you will need to work with the Active Directory Membership provider (so, not the Umbraco default, nor the Asp.Net Sql Membership Provider). You can find a good description of what needs to be done at the following url: http://msdn.microsoft.com/en-us/library/ff650308.aspx

    As far as the "auto-login" is concerned, I have never done this, but my guess is that if you configure IIS authentication to "Windows identity", the user might get recognized automatically if he is logged in on the intranet. But again, this is just my guess.

    Hope this helps you get further :-)

    Cheers,

    Michael.

  • david 46 posts 81 karma points
    Apr 12, 2011 @ 15:43
    david
    0

    Hi Jed, are you talking about members or users? There is a huge difference in Umbraco.  Using 

    User CurrentUser = User.GetCurrent();

    string UserName = CurrentUser.LoginName;

    should never produce a null when there is a user currently in logged into the backend

Please Sign in or register to post replies

Write your reply to:

Draft