SharePoint MOSS 2007: Hide MasterPage content based on SharePoint Security

less than 1 minute read

I found a nice blog post about hiding the top publishing toolbar from anonymous users:


http://www.sharepointplatform.com/teamblog/Lists/Posts/Post.aspx?ID=31


The code is simple, wrap all your .NET and HTML in the following tag, to hide it from everything but the



<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="BrowseDirectories">


<!-- HTML/.Net tags here to hide if not logged in -->


</Sharepoint:SPSecurityTrimmedControl>



With that, I was able to hide the entire top "control" bar, including the login link. Users who need to authenticate will need another link somewhere on the site, or they will need to bookmark a url like this:


http://<mystie>:<myport>/_layouts/AccessDenied.aspx?loginasanotheruser=true