Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

FormsAuthenticationTicket and changing LoginName control

$
0
0

I have written several in-house ASP.NET apps, many of which may need to be open at the same time in a browser in different tabs. All of these apps set the authentication ticket as such:

Dim authTicket As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, _
    FullName, DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, userData.ToString)

I am getting ready to start deploying some of these apps, and I have realized that when more than one app is opened in different tabs, as one app is logged into, it causes the other apps to log off, so basically they can only have one app going at a time. My thought was to add something to the name field in the ticket to make these tickets unique to each app, such as this:

Dim authTicket As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, _
    FullName & "*" & System.Configuration.ConfigurationManager.AppSettings("SiteName"), _
    DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, userData.ToString)

However, once I set the ticket that way, the LoginName control now shows not only the user name, but also the application name:

<div class="loginDisplay"><asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false"><AnonymousTemplate>
       [ <a href="~/Login/Login.aspx" id="HeadLoginStatus" runat="server">Log In</a> ]</AnonymousTemplate><LoggedInTemplate>
       Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
       [ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/" /> ]</LoggedInTemplate></asp:LoginView></div>

I need to know how I can intercept the process to modify the LoginName control and strip off everything after the "*" so that it only shows the user name. I'm looking for some help as to where/how I can do this. Thanks!


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>