参照Hunter的ABP-Zero模块中用户管理部分。

  由于我们公司的各系统基本都是AD帐号登录的,所以我们需扩展ABP的AuthenticationSource。

  • 添加MyLdapAuthenticationSource.cs及MyLdapSettings.cs

  Core层的Authorization目录下新建Ldap目录,并新建两个MyLdapAuthenticationSource.cs及MyLdapSettings.cs,代码如下:

  MyLdapAuthenticationSource.cs

public  class MyLdapAuthenticationSource : LdapAuthenticationSource<Tenant, User>
{
public MyLdapAuthenticationSource(ILdapSettings settings, IAbpZeroLdapModuleConfig ldapModuleConfig)
: base(settings, ldapModuleConfig)
{
}
}

  

  LdapAuthenticationSource的构造函数需要两个参数:ILdapSettings及IAbpZeroLdapModuleConfig,我们构造自己的MyLdapSettings:

  MyLdapSettings.cs

public class MyLdapSettings : ILdapSettings
{
private const string DomainName = "XXXX.com";
private const string Container = "OU=XXX,DC=XXXX,DC=com";
private const string UserName = "XXXX";
private const string Password = "XXXX";
private const string ADPath = "LDAP://XXXXX"; public async Task<bool> GetIsEnabled(int? tenantId)
{
return true;
} public async Task<ContextType> GetContextType(int? tenantId)
{ return ContextType.Domain;
} public async Task<string> GetContainer(int? tenantId)
{
return Container;
} public async Task<string> GetDomain(int? tenantId)
{
return DomainName;
} public async Task<string> GetUserName(int? tenantId)
{
return UserName;
} public async Task<string> GetPassword(int? tenantId)
{
return Password;
}
}

  

  • 在CoreModule中启用

  这里ILdapSettings我们使用MyLdapSettings来注册,但是IAbpZeroLdapModuleConfig使用默认的即可。

[DependsOn(typeof(AbpZeroCoreModule))]
public class CeciCoreModule : AbpModule
{
public override void PreInitialize()
{
Configuration.Auditing.IsEnabledForAnonymousUsers = true; IocManager.Register<IAbpZeroLdapModuleConfig, AbpZeroLdapModuleConfig>();
IocManager.Register<ILdapSettings, MyLdapSettings>(); //change default setting source
Configuration.Modules.ZeroLdap().Enable(typeof(MyLdapAuthenticationSource));
  • 重载认证逻辑

  目前我们只使用了Ldap最简逻辑,如需要复杂逻辑(如从AD中获得用户部门职位等),需重载LdapAuthenticationSource的方法来自定义实现。

  

ABP实战--集成Ladp/AD认证的更多相关文章

  1. Web API集成Azure AD认证

    1.声明的介绍 基于角色的授权管理,适用于角色变化不大,并且用户权限不会频繁更改的场景. 在更复杂的环境下,仅仅通过给用户分配角色并不能有效地控制用户访问权限. 基于声明的授权有许多好处,它使认证和授 ...

  2. php集成动态口令认证

    这篇文章主要为大家详细介绍了php集成动态口令认证,动态口令采用一次一密.用过密码作废的方式来提高安全性能,感兴趣的小伙伴们可以参考一下 大多数系统目前均使用的静态密码进行身份认证登录,但由于静态密码 ...

  3. 在Abp中集成Swagger UI功能

    在Abp中集成Swagger UI功能 1.安装Swashbuckle.Core包 通过NuGet将Swashbuckle.Core包安装到WebApi项目(或Web项目)中. 2.为WebApi方法 ...

  4. 使用NSURLSession请求需要AD认证的HTTPS服务器

    关键代码:使用后台下载PDF文件 - (void)startDownloadPDF{ NSURLSession *session = [self session]; NSString *downloa ...

  5. AD认证

    这两天接触到一个新的知识点,AD验证.什么是AD验证?Active Directory——活动目录,活动目录只是LDAP的一个实现,提供LDAP认证.Radius认证和NTML认证,都是标准认证方式 ...

  6. SharePoint2013基于Form(FBA)的AD认证登陆

    来源于:http://www.haogongju.net/art/1964313 1. 使用SharePoint2013实现基于AD的Form认证,首先创建一个Web Application,步骤如下 ...

  7. ASP.NET Core集成现有系统认证

    我们现在大多数转向ASP.NET Core来使用开发的团队,应该都不是从0开始搭建系统,而是老的业务系统已经在运行,ASP.NET Core用来开发新模块.那么解决用户认证的问题,成为我们的第一个拦路 ...

  8. # openVPN+LDAP AD认证,组权限管理

    # openVPN+LDAP AD认证,组权限管理 原创内容http://www.cnblogs.com/elvi/p/7661178.html # openVPN+LDAP AD认证,组权限管理 # ...

  9. jfinal集成cas单点认证实践

    本示例jfinal集成cas单点认证,采用获取到登录用户session信息后,在本地站点备份一份session信息,主要做以下几个步骤: 1.站点引入响应jar包: 2.在web.xml中配置对应过滤 ...

随机推荐

  1. 成员函数指针与高性能C++委托

    1 引子 标准C++中没有真正的面向对象的函数指针.这一点对C++来说是不幸的,因为面向对象的指针(也叫做“闭包(closure)”或“委托(delegate)”)在一些语言中已经证明了它宝贵的价值. ...

  2. 【算法33】LRU算法

    题目来源 LeetCode: https://leetcode.com/problems/lru-cache/ LRU简介 LRU (Least Recently Used,最近最少使用)算法是操作系 ...

  3. Docker load与Docker import

    docker load与docker import   首先,想要清楚的了解docker load与docker import命令的区别,就必须了解镜像与容器的区别: 镜像:用来启动容器的只读模板,是 ...

  4. 反射导出 Excel

    /// <summary> /// List 数据导出Excel /// </summary> /// <param name="list">数 ...

  5. OSLab课堂作业2

      日期:2019/3/23 内容: 实现内容 要求 mysys.c 实现函数mysys,用于执行一个系统命令. mysys的功能与系统函数system相同,要求用进程管理相关系统调用自己实现一遍 使 ...

  6. sql语句_统计总成绩最高的前2名

    有一个数据表,id user_id score 三个字段,计算总成绩最高的前两名 SELECT * FROM (SELECT user_name,SUM(score) AS score FROM us ...

  7. 2018年Android面试题含答案--适合中高级(下)

    这里是我整理出来的面试题,答案我花了很久的时间.加上我自己的理解整理出来的,作者不易,请谅解.有答案的的:https://xiaozhuanlan.com/topic/6132940875   1.A ...

  8. tomcat apr Dockfile

    基于 centos7.4 jdk1.7 RUN yum makecache && yum --nogpgcheck -y groupinstall 'Development Tools ...

  9. 访问www.baidu.com后会发生什么(一次完整的网络通讯过程)

    1.在浏览器中输入www.baidu.com 这意味着浏览器要向百度发送一个网页数据包,要发送数据包,需要知道对方的IP地址,这里我们只知道网址为www.baidu.com,却不知道IP地址,此时应用 ...

  10. [Swift实际操作]七、常见概念-(1).范围Range、ClosedRange和NSRange的使用实际操作

    本文将为你解析区间的概念.在对字符串进行处理时,经常会使用到区间.例如获得字符串中从某个位置开始到另一个位置之间的内容. 首先导入需要使用到的框架 import Foundation 区间分为闭区间和 ...