版权声明:本文为博主原创文章,未经博主同意不得转载。 https://blog.csdn.net/u012025054/article/details/37565787

SharePoint 2010 在同意匿名訪问的站点中隐藏登陆链接

        近期在使用Welcome.ascx用户控件时,发现非常多东西都是要靠它来呈现。

比方这里,关于在站点中对于匿名訪问用户隐藏登陆链接也与它有关。

        大概分两个步骤完毕这样功能。非常easy。须要用到母版页和SharePoint Application Page link控件。

1. 复制Welcome.ascx控件,命名CustomWelcome.ascx。覆盖OnLoad事件,给匿名用户隐藏登陆应用程序页面链接。
2. 在母版页中引用这个自己定义的CustomWelcome.ascx。
        在C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES中你会找到Welcome.ascx文件,复制后打开CustomWelcome.ascx文件。你会看到对于验证用户。非常多菜单项如我的设置、以其它用户身份登陆、注销等是可用的。在ID“ExplicitLogOut”下全部菜单项是可用的。你能够看到,Personal Actions控件是不可见的,当用户被成功验证后可见。

<%@ 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" />

        这个链接我们须要研究一下。默认是不可见的。当用户未被认证时出现。也就是匿名用户看到的。这样他们就能够登陆了。

        我们在CustomWelcome.ascx控件中加入脚本。覆盖OnLoad事件。为非验证用户隐藏ExplicitLogin链接。
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"后,刷新首页。

恢复正常。

        假设你看懂了Welcome.ascx文件及其结构。你会发现自己定义变得easy并且有趣。

SharePoint 2010 在同意匿名訪问的站点中隐藏登陆链接的更多相关文章

  1. 匿名訪问之(一)web application级别

    假设用SharePoint做一个对外开放的公共站点,比方公司展示站点.那么浏览站点的人不须要注冊和登陆.就应该能看到内容.这个时候就须要对站点开启匿名訪问. SharePoint的匿名訪问是从上而下的 ...

  2. MYSQL加入远程用户或同意远程訪问三种方法

    加入远程用户admin密码为password GRANT ALL PRIVILEGES ON *.* TO admin@localhost IDENTIFIED BY \'password\' WIT ...

  3. 您可能试图从server上的安全浏览器訪问此站点。请启用脚本然后又一次载入此页。

    您可能试图从server上的安全浏览器訪问此站点.请启用脚本然后又一次载入此页.         我使用域Admin组的账户登入SharePoint2010的server,打开SharePoint首页 ...

  4. [Phonegap+Sencha Touch] 移动开发76 让cordova app訪问远端站点也能调用cordova插件功能

    原文链接:http://blog.csdn.net/lovelyelfpop/article/details/50735395 我相信.应该会有一些cordova开发人员想过实现以下这种app: 使用 ...

  5. SharePoint 2013 开启訪问请求

    1.通常,我们进入SharePoint 2013网站,假设没权限会提示该网站未被共享,而没有切换账号或者申请訪问,实在是非常流氓:事实上,SharePoint为我们提供了訪问请求页面.可是可能须要手动 ...

  6. 设计模式之二十四:訪问者模式(Visitor)

    訪问者模式: 定义了一个作用于一个类的一些操作,訪问者模式同意在不改变类的前提下添加一些操作. Represent an operation to be performed on the elemen ...

  7. 关于Apacheserver的訪问控制

    Apache的訪问控制指对不论什么资源的不论什么方式的訪问控制. 一.基于主机或者IP地址的控制 这样的訪问控制基于訪问者的主机名或者IP地址,通过使用 Deny 和 Allow 指令.实现同意或者禁 ...

  8. Android 訪问权限清单

    Android权限设置 概述 权限 说明 訪问登记属性 android.permission.ACCESS_CHECKIN_PROPERTIES 读取或写入登记check-in数据库属性表的权限 获取 ...

  9. 设计模式之十五:訪问者模式(Visitor Pattern)

    訪问者模式(Visitor Pattern)是GoF提出的23种设计模式中的一种,属于行为模式. 据<大话设计模式>中说算是最复杂也是最难以理解的一种模式了. 定义(源于GoF<De ...

随机推荐

  1. mybatis插件机制

    目录 mybatis插件机制 主要 类/接口 和 方法 mybatis插件机制实现 mybatis插件机制 mybatis的插件机制使用动态代理实现,不了解的朋友请先了解代理模式和动态代理:插件本质是 ...

  2. crontab命令行和日志查看

    1.基本命令行模式 注意:非root用户 systemctl restart crond 失效,请使用最底层的驱动重启 2.crontab日志 cron日志保存在系统目录/var/log/cron 命 ...

  3. Exception 和 Error 有什么区别么

    声明 本篇所涉及的提问,正文的知识点,全都来自于杨晓峰的<Java核心技术36讲>,当然,我并不会全文照搬过来,毕竟这是付费的课程,应该会涉及到侵权之类的问题. 所以,本篇正文中的知识点, ...

  4. markdown 语法指南

    说明:左边是markdown的语法 右边是预览.(我这里用了黑色的背景,一般白色较多) 1. 标题 2.列表 3.引用 (1)一层引用 (2)多层引用 4.图片(如果是本地:按照语法写图片路径:如果是 ...

  5. angularJS中控制器和作用范围

    $scope是$rootScope的子作用域控制对象,$rootScope的id为1,其他的为2,3,4... 不同的控制器之间,所对应的作用域控制对象$scope,之间是相互隔离的,如果要共享数据, ...

  6. 浅谈EditText控件的inputType类型

    android:inputType="none"--默认 android:inputType="text"--输入文本字符 android:inputType= ...

  7. WPF:解决DataGrid横向滚动条无法显示的问题

    DataGrid的最后一列的宽度设置为“Width=”auto””即可. 如果显示指定长度或者设置为“*”,那么不管怎么拖动列头,或者不管行里面的内容有没有超过DataGrid的显示区域,DataGr ...

  8. 使用C#+PowerShell进行Windows系统间文件传输

    新的winserver2016支持了一种nano模式,像以前的core模式,只能远程管理,只支持x64,只有610M,不让CentOS mini版独美. 这个nano版,默认只开启WinRM,所以只能 ...

  9. android build 编译打印详细过程

    我们在make otapackage编译android代码的时候,有时候需要跟踪详细的过程,包括所有的过程,可以修改build/core/Makefile,赋值hide := 为空即可

  10. Python学习手记

    1.Python大小敏感.print写作PRINT或Print是不对.2.注释符是“#”,而非“//”.3.语句结尾不必须分号.4.转义符为“/”+转义字母.这点与刀莱特一致.5.单引号输入使用“/' ...