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?
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
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.
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.
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.
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
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
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
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
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.
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
is working on a reply...