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

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

  • 添加MyLdapAuthenticationSource.cs及MyLdapSettings.cs

  Core层的Authorization目录下新建Ldap目录,并新建两个MyLdapAuthenticationSource.csMyLdapSettings.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. 【Win10】页面的导航效果

    CommonNavigationTransitionInfo ContinuumNavigationTransitionInfo DrillInNavigationTransitionInfo Ent ...

  2. Oracle Client 连接 Server 并通过代码测试连接

    Oracle客户端配置 步骤一: 步骤二: 步骤三: 步骤四: 步骤五: 最后测试成功   注: 如果是客户端配置可以不用添加 程序同样可以进行连接,如果是服务器则需要配置. 程序连接 namespa ...

  3. android RadioButton文字居中的方法

    每个RadioButton的style原先是这样的: <style name="radiobutton_style" > <item name="and ...

  4. 关于linq的几个小例子

    private void button1_Click(object sender, EventArgs e) { ] { ,,,,,,}; var result0 = from num in numb ...

  5. Office - Outlook

    将邮件存到本地 服务器容量有限,避免丢失和经常提示容量不足 步骤 在File->Account Settings->Account Settings下面 在Data Files标签页新建一 ...

  6. 深度认识 Sharding-JDBC:做最轻量级的数据库中间层

    转自: https://juejin.im/entry/5905ac37a22b9d0065e1199c 基于关系型数据库的水平扩展方案有很多开源的解决方案,但成熟稳定的产品凤毛麟角.当当自研的数据库 ...

  7. iOS Block初探

    //https://www.jianshu.com/p/d28a5633b963 #import <Foundation/Foundation.h> void (^FFGlobalBloc ...

  8. poj3070 Fibonacci(矩阵快速幂)

    矩阵快速幂基本应用. 对于矩阵乘法与递推式之间的关系: 如:在斐波那契数列之中 f[i] = 1*f[i-1]+1*f[i-2]  f[i-1] = 1*f[i-1] + 0*f[i-2].即 所以, ...

  9. Smarty的原理_面试

    Smarty是一个模板引擎,使用smarty主要是为了实现逻辑和外在内容的分离,如果不使用模板的话,通常的做法就是php代码和html代码混编.使用了模板后,则可以将业务逻辑放到php文件中,而负责显 ...

  10. win8 下 intellij idea 13 中文输入覆盖的问题

    网上的解决方案好啰嗦,精简下如下: 设置环境变量 64位:IDEA_JDK_64 32位:IDEA_JDK 设置的value必须是JDK1.6(IDEA自带1.7版本有问题),和平时设置的JAVA_H ...