zoukankan      html  css  js  c++  java
  • sharepoint匿名实现的另一种方法

    1. 新建一个区域 82

    2. 设置MemberShipProvider

    代码
    public override bool ValidateUser(string username, string password)
    {
    if (username == "guest")
    return true;
    else
    return false;
    }

    public override MembershipUser GetUser(string username, bool userIsOnline)
    {
    if (username == "guesT")
    return new MembershipUser(this.Name, "Guest", "Guest", string.Empty, string.Empty, string.Empty, true, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue);
    return null;
    }

    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
    {
    totalRecords
    = 1;
    MembershipUserCollection userCollection
    = new MembershipUserCollection();
    userCollection.Add(
    new MembershipUser(this.Name, "Guest", "Guest", string.Empty, string.Empty, string.Empty, true, false, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue));
    return userCollection;
    }

    public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
    {
    if (string.Format("guest").Contains(usernameToMatch))
    return GetAllUsers(1, 1, out totalRecords);
    else
    {
    totalRecords
    = 0;
    return new MembershipUserCollection();
    }
    }
    

    3. 配置82站点为匿名访问, 设置MemberShipProvider

    4. 更改82的global.ashx文件

    代码
    1 <script RunAt='server'>
    2 protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    3 {
    4 string cookieName = FormsAuthentication.FormsCookieName;
    5 HttpCookie authCookie = Context.Request.Cookies[cookieName];
    6 if (authCookie == null)
    7 {
    8 FormsAuthentication.SetAuthCookie("guest", false);
    9 }
    10 }
    11  </script>
  • 相关阅读:
    thymeleaf时间戳转换
    alerttemplate 时间戳转换
    jQuery.Deferred exception: a.indexOf is not a function TypeError: a.indexOf is not a function
    区分数据是对象还是字符串
    eclipse中选取一列快捷键
    图片拉伸不变型
    这里ajax需要改成同步
    idea如何整理代码格式
    20170311-起早床
    20190310-解决头屑
  • 原文地址:https://www.cnblogs.com/frankzye/p/1836937.html
Copyright © 2011-2022 走看看