Technical Speaking

Trying to make life easier for SharePoint people
posts - 57, comments - 53, trackbacks - 2

My Links

News


MJ Ferdous

MJ Ferdous is an IT professional from 7 years ago.

He is Technical Project Manager of Congral LLC, USA and SharePoint Consultant as well. He has industry level experience on SharePoint Server (MOSS 2007/2010) and did lots of Presentation & workshop on SharePoint.

He did work in OT Group SPA,Italy as SharePoint Consultant. He did lot of international projects during his professional life. For example: Software development for Internet Banking Portal, TCI on Canadian tourism sector, Rockwell MES solution for international pharmaceuticals companies and so on. He is the author of several technical article.

He is also Technical Author of DevMedia Group(Mrbool.com) as well as owner & modaretor of several groups of sharepoint and asp.net.. Looking for a Offshore Development partnership.............. in ASP.Net & Sharepoint 2007,2010.

invisible hit counter View My Stats

Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

Blogs [MVP]

My Articles

My Others Link

Public Speaking

Sharepoint: Best way of hiding the “Sign in” link in the client web browser

It is a common problem in the sharepoint 2007 developemt to hide the “Sign in” link in the client web browser. I didnt find any perfect solution for that. Let's think one scenario. For example, You are developing a WCM website in MOSS and have two entry points to the website - one web app for internal use to edit the site (i.e. you have to authenticate), and one for the website (i.e. for anonymous access).

You have created a master page which obviously has to contain controls that allow users to log in and author content. However since the same master page is used for both web apps, you need to hide those controls when the site's being accessed anonymously. You don't want there to be a 'Sign in' link when viewed anonymously.
 


 

The main concept is to hide "sign in" link only from the public site or "sign in" link will be visible only in the source Application/Server not in the Destination Server Farm in case of Content Deployment. At the begining, I was implemented by CSS hiding Script using Content Editor Web part in the Default.aspx of Destination server (Farm B) to remove top section from public site like the following code but when I execute Content Re-deploy from Source to destination farm (i.e. We have two server farm), it overwrites the “default.aspx” and remove the script. So you have to do it manually in each deployment.

<style type="text/css">

 .ms-globalbreadcrumb,
 .ms-bannerContainer,
 .ms-globalTitleArea,
 { 
   display: none;  }
</Style>

This is one problem and another problem is “Sign in” link only hide from the root default page not for all sub sites default page. Because we added this script only for the root app default (i.e. Http://server1:4242/Pages/ Defaut.aspx) page. So if the users go to http://server1:4242/Sub/Pages/Default.aspx . “Sign in” link still appears. Also it won’t work event if we implement in custom web part until and unless we add it in every sub site default pages.

However, I was look for the solution in the internet. Most of the solution doesn't work for the above reason. I tried to solve it in different way. For sure, we have to customize the master page to remove “sign in” otherwise it will not remove totally from the all other pages of the site.

The Question is how? If you can identify the application then you can control the hiding and showing properly. For example, when the root (Default Zone) application is run in the development environment then the sign-in bar will be shown otherwise not. So, I checked the server name/IP and port pragmatically then show in for the specific zone using C# inline code on master page. You can reuse the asp.net ContainPlaceHolder Control to hide and show using the following code:

Add this script inside <HEAD> of Default.master page

<script type="text/c#" runat="server">

        protected void Page_Load(object sender, EventArgs e)  {

          string add = Request.ServerVariables["SERVER_NAME"];

          string port = Request.ServerVariables["SERVER_PORT"];

          string requestAdd = add + "/" + port;

          string defautZone = "server1/34567";

                if (requestAdd == defautZone )   {                    

                        PlaceHolderGlobalNavigation.Visible = true;

                }

        }

 </script>

 Add Visible=false to hide the specific content

<asp:ContentPlaceHolder id="PlaceHolderGlobalNavigation" runat="server" Visible="false">

……

</asp:ContentPlaceHolder>

And so on..

If you implement it well then it would be perfect solution that in the source application “sign in” will be only visible otherwise always false.

There is only one disadvantage in this case. You have to customize master page. It is better to avoid editing master page. So, I would prefer to copy master page and modify that and Change the master page from your layout.

One Important Thing is: If you saved the master page now and opened the site in our browser you will get an error about not being able to run code blocks. There’s an extra line you need to put into your web.config file first to allow this inline c# to execute.

<PageParserPaths>
        <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>

The PageParserPaths xml tags are already be there. You just need to add the line in between. Save web.config and off you go. Your pages will render properly and the c# inline code will execute.

Note:  you can try to get the server name from the web.config file if there is a possibility to change source/development server so that you do not need to rewrite again in the master page when the server change. Then you can only change in the configuration file.

Thanks in advance for Feedback

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Thursday, September 25, 2008 3:05 AM | Filed Under [ ASP.Net Sharepoint 2007 ASP.Net 3.5 ASP.Net 2.0 C# Office 2007 Microsoft Office SharePoint Server 2007 Microsoft Office SharePoint Designer 2007 ]

Feedback

Gravatar

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

I hope This post will be helpfull for all of you who want to hide something from sharepoint public site
9/26/2008 1:54 AM | MJ
Gravatar

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

hi

good article.but its not working for me.
its again showing "Sign In" in my site.
can u help me.

with Regards,
obulreddy
9/24/2009 5:36 AM | obulreddy
Gravatar

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

hi

good article.but its not working for me.
its again showing "Sign In" in my site.
can u help me.

with Regards,
obulreddy
10/3/2009 2:00 AM | obulreddy
Gravatar

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

Hi obulreddy,

Did you use ContentPlaceHolder properly??

If you use it properly then check id Page_Load executes properly or not??

I think you Page_Load is not executing properly.
10/3/2009 2:04 AM | Admin
Gravatar

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

This is the only solution in the Internet that works for me, when we have different domains for intranet and internet.

Thanks MJ!
10/16/2009 9:24 AM | Rui Alves
Gravatar

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

PageParserPaths should not be used specially on public sites.. it can be a big security hole.. also u can hide sign in button from master page itself
11/5/2009 2:42 PM | Sandeep
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: