Geeks With Blogs

News invisible hit counter View My Stats

Technical Speaking

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

Posted on Thursday, September 25, 2008 3:05 AM 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 | Back to top


Comments on this post: Sharepoint: Best way of hiding the “Sign in” link in the client web browser

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser
Requesting Gravatar...
I hope This post will be helpfull for all of you who want to hide something from sharepoint public site
Left by MJ on Sep 26, 2008 1:54 AM

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

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

with Regards,
obulreddy
Left by obulreddy on Sep 24, 2009 5:36 AM

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

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

with Regards,
obulreddy
Left by obulreddy on Oct 03, 2009 2:00 AM

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser
Requesting Gravatar...
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.
Left by Admin on Oct 03, 2009 2:04 AM

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser
Requesting Gravatar...
This is the only solution in the Internet that works for me, when we have different domains for intranet and internet.

Thanks MJ!
Left by Rui Alves on Oct 16, 2009 9:24 AM

# re: Sharepoint: Best way of hiding the “Sign in” link in the client web browser
Requesting Gravatar...
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
Left by Sandeep on Nov 05, 2009 2:42 PM

Your comment:
 (will show your gravatar)


Copyright © MJ Ferdous | Powered by: GeeksWithBlogs.net