Sunday, October 12, 2008  by Marc Charmois - About Me / Previous Posts / Archives - Home

Hide the “Sign in” link in the client web browser for anonymous users

do you want to hide the sign-in link on your SharePoint sites for your internet users that access it in anonymous authentication mode?
Well, there is one simple and very quick way to do this with 2 scripts in your master page using C# + JavaScript. The effect will be that the link will not be present for anonymous user, but authenticated users will see Welcome and Action menus.

In the head section of your master page place this code :
         Response.Write("var isAuthenticated =" +System.Web.HttpContext.Current.User.Identity.IsAuthenticated.ToString().ToLower() +";");
Wrap your menu elements with a container and give it an Id :

         <td id="MenuElements" class="ms-MenuElements"> 
             <wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"></wssuc:Welcome>
             <PublishingSiteAction:SiteActionMenu runat="server" />

At the end of your master page place this javaScript code :

And it's done !
Warning :
Don't forget to replace the in line code in the master page later, by an User Control or a Custom control, as the in line code will fail if the master page is customized...

Labels: , , , ,


Anonymous Anonymous said...

why not use a security trimmed control instead?

January 23, 2009 at 3:25 AM  
Blogger Marc Charmois said...

You mean that way ?

<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageLists">
Place your control(s) here

Unfortunatly, there is no item in SPBasePermissions Enumeration that specifies if user is authenticated or not.

January 26, 2009 at 5:35 PM  
Anonymous Anonymous said...

You don't need a SPBasePermissions Enumeration that specifies if user is authenticated or not. The unauthenticated user dosen't have the right to ManageLists, so it's working.

May 6, 2009 at 10:43 PM  
Blogger Marc Charmois said...

Ok, then Authenticated users that cannot manage lists will not see the "Sign in" link... :-)

May 7, 2009 at 6:02 AM  
Anonymous Anonymous said...

Try this

< asp:LoginView runat="server">
< LoggedInTemplate>

authenticated users content
anonymous content

October 14, 2009 at 5:23 PM  
Anonymous Anonymous said...

"asp:LoginView" is the most simplest and streight forward means of rendering Authanticarted and Anonymous content respectivly.


March 30, 2010 at 4:43 AM  
Blogger Unknown said...

Just found this post as part of some research I'm doing to solve the same problem.

I'm unclear about your warning. You state "Don't forget to replace the in line code in the master page later..."

In the your example code, what code needs to be replaced, and replaced with what?

I thought I could implement your example code and like you said "And it's done." But your warning implies there is something else to be done before i walk away.

I admit, I still havent found time to try your code. Will do soon.


August 27, 2013 at 8:41 PM  

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home