SharePoint 2010 在允许匿名访问的网站中隐藏登陆链接
SharePoint 2010 在允许匿名访问的网站中隐藏登陆链接
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Control Language="C#" Inherits="Microsoft.SharePoint.WebControls.Welcome,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" AutoEventWireup="false" compilationMode="Always" %> <SharePoint:PersonalActions accesskey="<%$Resources:wss,personalactions_menu_ak%>" ToolTip="<%$Resources:wss,open_menu%>" runat="server" id="ExplicitLogout" Visible="false"> <CustomTemplate> <SharePoint:FeatureMenuTemplate runat="server" FeatureScope="Site" Location="Microsoft.SharePoint.StandardMenu" GroupId="PersonalActions" id="ID_PersonalActionMenu" UseShortId="true" > <SharePoint:MenuItemTemplate runat="server" id="ID_PersonalInformation" Text="<%$Resources:wss,personalactions_personalinformation%>" Description="<%$Resources:wss,personalactions_personalinformationdescription%>" MenuGroupId="100" Sequence="100" ImageUrl="/_layouts/images/menuprofile.gif" UseShortId="true" /> <SharePoint:MenuItemTemplate runat="server" id="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="200" Sequence="100" UseShortId="true" /> <SharePoint:MenuItemTemplate runat="server" id="ID_RequestAccess" Text="<%$Resources:wss,personalactions_requestaccess%>" Description="<%$Resources:wss,personalactions_requestaccessdescription%>" MenuGroupId="200" UseShortId="true" Sequence="200" /> <SharePoint:MenuItemTemplate runat="server" id="ID_Logout" Text="<%$Resources:wss,personalactions_logout%>" Description="<%$Resources:wss,personalactions_logoutdescription%>" MenuGroupId="200" Sequence="300" UseShortId="true" /> <SharePoint:MenuItemTemplate runat="server" id="ID_PersonalizePage" Text="<%$Resources:wss,personalactions_personalizepage%>" Description="<%$Resources:wss,personalactions_personalizepagedescription%>" ImageUrl="/_layouts/images/menupersonalize.gif" ClientOnClickScript="javascript:ChangeLayoutMode(true);" PermissionsString="AddDelPrivateWebParts,UpdatePersonalWebParts" PermissionMode="Any" MenuGroupId="300" Sequence="100" UseShortId="true" /> <SharePoint:MenuItemTemplate runat="server" id="ID_SwitchView" MenuGroupId="300" Sequence="200" UseShortId="true" /> <SharePoint:MenuItemTemplate runat="server" id="MSOMenu_RestoreDefaults" Text="<%$Resources:wss,personalactions_restorepagedefaults%>" Description="<%$Resources:wss,personalactions_restorepagedefaultsdescription%>" ClientOnClickNavigateUrl="javascript:SP.SOD.execute('browserScript', 'MSOWebPartPage_RestorePageDefault')" MenuGroupId="300" Sequence="300" UseShortId="true" /> </SharePoint:FeatureMenuTemplate> </CustomTemplate> </SharePoint:PersonalActions>另一部分是作为SharePoint Application Page Link的用户控件ExplicitLogin。
<SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin" ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true Text="<%$Resources:wss,login_pagetitle%>" style="display:none" Visible="false" />这个链接我们需要研究一下。默认是不可见的;当用户未被认证时出现。也就是匿名用户看到的。这样他们就可以登陆了。
protected override void OnLoad(EventArgs e) { //base.OnLoad(e); base.OnLoad(e); if (HttpContext.Current.User.Identity.IsAuthenticated) { this.ExplicitLogout.Visible = true; } else { this.ExplicitLogin.Visible = false; this.ExplicitLogin.Attributes.CssStyle.Add("display", "block"); } }在母版页引用这个自定义的CustomWelcome.ascx文件。
<%@ Register TagPrefix="wssuc" TagName="CustomWelcome" src="~/_controltemplates/CustomWelcome.ascx" %>
<wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"></wssuc:Welcome>添加Visible="False"后,刷新首页。恢复正常。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。