加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何为ASP.NET托管的ICS iCalendar for outlook添加身份验

发布时间:2020-12-15 04:21:11 所属栏目:百科 来源:网络整理
导读:我有一个ASP.NET应用程序,它动态创建一个ICS日历( using the DDay.iCal library),我可以从outlook中订阅.一切正常,但我需要能够保护日历,以便只有经过身份验证的用户才能访问它.即,当您将URL添加到Outlook中的日历时,它需要询问用户名和密码. Remember The M
我有一个ASP.NET应用程序,它动态创建一个ICS日历( using the DDay.iCal library),我可以从outlook中订阅.一切正常,但我需要能够保护日历,以便只有经过身份验证的用户才能访问它.即,当您将URL添加到Outlook中的日历时,它需要询问用户名和密码.

Remember The Milk seem to have implemented what I need,但我似乎无法找到有关如何实现这一目标的任何信息?

解决方法

The article Chris provided as a comment是解决方案.

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

这是通过使用MADAM Http Module实现的.

脚步:

1 GT;阅读文章以获得基本的了解.

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

3 GT;实现自己的IUserSecurityAuthority:

例如

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>将以下内容添加到您的Web配置中:

例如:

<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>

注1:

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

…用于识别哪些请求应绕过表单身份验证并使用基本HTTP身份验证,这是使用Regex完成的,您可以添加多个鉴别符.

笔记2:

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读