• 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>
  • 相关阅读:
    【转】iPython入门技巧
    Python——IPython和NumPy
    Python——类与对象,异常处理
    Python——函数,模块,简单文件读写
    给对象的key 设置成变量
    antd 表单validateFields validateFieldsAndScroll方法不执行
    css 设置禁用
    where与having区别
    重温robotframework--day1
    Linux下查看文件内容的命令
  • 原文地址:https://www.cnblogs.com/frankzye/p/1836937.html
Copyright © 2020-2023  润新知