如何向 ASP.NET 托管的 ICS iCalendar for Outlook 添加身份验证

2024-04-02

我有一个 ASP.NET 应用程序,它动态创建 ICS 日历(使用 DDay.iCal 库 http://rbalajiprasad.blogspot.co.uk/2012/11/mvc-c-create-ical-calendar-ics-feed.html)我可以从 Outlook 中订阅。一切工作正常,但我需要能够保护日历,以便只有经过身份验证的用户才能访问它。即,当您将 URL 添加到 Outlook 中的日历时,它需要询问用户名和密码。

记住牛奶似乎已经实现了我所需要的 https://www.rememberthemilk.com/help/?ctx=feeds.icalendar.howsubscribe.microsoftoutlook,但我似乎找不到任何有关如何自己实现这一目标的信息?


克里斯提供的文章作为评论 http://msdn.microsoft.com/en-us/library/aa479391.aspx就是解决方案。

所需要的是对某些请求绕过表单身份验证并使用基本 HTTP 身份验证。 Outlook(以及可能的其他代理,如 Web 浏览器)将支持此功能。

这是通过使用MADAM Http 模块 http://www.raboof.com/projects/madam/.

Steps:

1> 阅读文章以获得基本了解。

2> 安装 MADAM NuGet 包:PM> 安装包女士

3> 实现你自己的用户安全机构:

e.g

public class MadamUserSecurityAuthority : IUserSecurityAuthority
{
    public MadamUserSecurityAuthority()
    {

    }

    //This constructor is required
    public MadamUserSecurityAuthority(IDictionary options)
    {

    }

    public object Authenticate(string userName, object password, PasswordFormat format, IDictionary options, string authenticationType)
    {
        if (_yourAuthenticationService.isValid(userName, password.ToString()))
            return true;

        //Returning null means the authentication failed
        return null;
    }

    public string RealmName
    {
        get { return "MADAM"; }
    }
}

4> 将以下内容添加到您的网络配置中:

eg:

<sectionGroup name="madam">
    <section name="userSecurityAuthority" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <section name="formsAuthenticationDisposition" type="Madam.FormsAuthenticationDispositionSectionHandler, Madam"/>
</sectionGroup>  

<madam>
    <formsAuthenticationDisposition>
        <discriminators all="true">
            <discriminator inputExpression="Request.Url" pattern="Calendar\.aspx" type="Madam.RegexDiscriminator"/>
        </discriminators>
    </formsAuthenticationDisposition>
    <userSecurityAuthority realm="MADAM" provider="YourAppAssembly.MadamUserSecurityAuthority, YourAppAssembly"/>
</madam>

<httpModules>
  <add name="FormsAuthenticationDisposition" type="Madam.FormsAuthenticationDispositionModule, Madam"/>
  <add name="AuthenticationModule" type="Madam.BasicAuthenticationModule, Madam"/>      
</httpModules>

Note 1:

<discriminator inputExpression="Request.Url" pattern="Calendar\.aspx" type="Madam.RegexDiscriminator"/>

...用于识别哪些请求应绕过表单身份验证并使用基本 HTTP 身份验证,这是通过正则表达式完成的,并且您可以添加多个鉴别器。

Note 2:

<userSecurityAuthority realm="MADAM" provider="YourAppAssembly.MadamUserSecurityAuthority, YourAppAssembly"/> 

....是您配置自定义身份验证提供程序的位置(即根据数据库检查凭据的位置)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何向 ASP.NET 托管的 ICS iCalendar for Outlook 添加身份验证 的相关文章

  • 无法使用已与其底层 RCW 分离的 COM 对象。在 oledb 中

    我收到此错误 但我不知道我做错了什么 下面的代码在backrgroundworker中 将异常详细信息复制到剪贴板 System Runtime InteropServices InvalidComObjectException 未处理 通
  • 是否可以强制 XMLWriter 将元素写入单引号中?

    这是我的代码 var ptFirstName tboxFirstName Text writer WriteAttributeString first ptFirstName 请注意 即使我使用 ptFirstName 也会以双引号结束 p
  • 将数组向左或向右旋转一定数量的位置,复杂度为 o(n)

    我想编写一个程序 根据用户的输入 正 gt 负 include
  • linux perf:如何解释和查找热点

    我尝试了linux perf https perf wiki kernel org index php Main Page今天很实用 但在解释其结果时遇到了困难 我习惯了 valgrind 的 callgrind 这当然是与基于采样的 pe
  • Newtonsoft JSON PreserveReferences处理自定义等于用法

    我目前在使用 Newtonsoft Json 时遇到一些问题 我想要的很简单 将要序列化的对象与所有属性和子属性进行比较以确保相等 我现在尝试创建自己的 EqualityComparer 但它仅与父对象的属性进行比较 另外 我尝试编写自己的
  • WPF 中的调度程序和异步等待

    我正在尝试学习 WPF C 中的异步编程 但我陷入了异步编程和使用调度程序的困境 它们是不同的还是在相同的场景中使用 我愿意简短地回答这个问题 以免含糊不清 因为我知道我混淆了 WPF 中的概念和函数 但还不足以在功能上正确使用它 我在这里
  • C - 找到极限之间的所有友好数字

    首先是定义 一对友好的数字由两个不同的整数组成 其中 第一个整数的除数之和等于第二个整数 并且 第二个整数的除数之和等于第一个整数 完美数是等于其自身约数之和的数 我想做的是制作一个程序 询问用户一个下限和一个上限 然后向他 她提供这两个限
  • Qt moc 在头文件中实现?

    是否可以告诉 Qt MOC 我想声明该类并在单个文件中实现它 而不是将它们拆分为 h 和 cpp 文件 如果要在 cpp 文件中声明并实现 QObject 子类 则必须手动包含 moc 文件 例如 文件main cpp struct Sub
  • C# 中的递归自定义配置

    我正在尝试创建一个遵循以下递归结构的自定义配置部分
  • for循环中计数器变量的范围是多少?

    我在 Visual Studio 2008 中收到以下错误 Error 1 A local variable named i cannot be declared in this scope because it would give a
  • 实体框架 4 DB 优先依赖注入?

    我更喜欢创建自己的数据库 设置索引 唯一约束等 使用 edmx 实体框架设计器 从数据库生成域模型是轻而易举的事 现在我有兴趣使用依赖注入来设置一些存储库 我查看了 StackOverflow 上的一些文章和帖子 似乎重点关注代码优先方法
  • 如何使我的表单标题栏遵循 Windows 深色主题?

    我已经下载了Windows 10更新包括黑暗主题 文件资源管理器等都是深色主题 但是当我创建自己的 C 表单应用程序时 标题栏是亮白色的 如何使我自己的桌面应用程序遵循我在 Windows 中设置的深色主题 你需要调用DwmSetWindo
  • 需要哪个版本的 Visual C++ 运行时库?

    microsoft 的最新 vcredist 2010 版 是否包含以前的版本 2008 SP1 和 2005 SP1 还是我需要安装全部 3 个版本 谢谢 你需要所有这些
  • 如何让Gtk+窗口背景透明?

    我想让 Gtk 窗口的背景透明 以便只有窗口中的小部件可见 我找到了一些教程 http mikehearn wordpress com 2006 03 26 gtk windows with alpha channels https web
  • WCF:将随机数添加到 UsernameToken

    我正在尝试连接到用 Java 编写的 Web 服务 但有些东西我无法弄清楚 使用 WCF 和 customBinding 几乎一切似乎都很好 除了 SOAP 消息的一部分 因为它缺少 Nonce 和 Created 部分节点 显然我错过了一
  • 为什么 C# Math.Ceiling 向下舍入?

    我今天过得很艰难 但有些事情不太对劲 在我的 C 代码中 我有这样的内容 Math Ceiling decimal this TotalRecordCount this PageSize Where int TotalRecordCount
  • 如何使用 std::string 将所有出现的一个字符替换为两个字符?

    有没有一种简单的方法来替换所有出现的 in a std string with 转义 a 中的所有斜杠std string 完成此操作的最简单方法可能是boost字符串算法库 http www boost org doc libs 1 46
  • ASP.NET MVC 6 (ASP.NET 5) 中的 Application_PreSendRequestHeaders 和 Application_BeginRequest

    如何在 ASP NET 5 MVC6 中使用这些方法 在 MVC5 中 我在 Global asax 中使用了它 现在呢 也许是入门班 protected void Application PreSendRequestHeaders obj
  • 防止索引超出范围错误

    我想编写对某些条件的检查 而不必使用 try catch 并且我想避免出现 Index Out of Range 错误的可能性 if array Element 0 Object Length gt 0 array Element 1 Ob
  • 恢复上传文件控制

    我确实阅读了以下帖子 C 暂停 恢复上传 https stackoverflow com questions 1048330 pause resume upload in c 使用 HTTP 恢复上传 https stackoverflow

随机推荐