Giter Site home page Giter Site logo

abp.ldap's Introduction

Abp Vnext Ldap 模块

Build NuGetVersion NuGet Download

安装Nuget包

dotnet add package iBestRead.Abp.Ldap

配置

修改appsettings.json文件:

"LDAP": {
    "ServerHost": "127.0.0.1",}
    "ServerPort": 636,```
    "UseSSL": true,
    "Credentials": {
        "DomainUserName": "[email protected]",
        "Password": "yourPassword"
    },
    "SearchBase": "CN=Users,DC=yourDomain,DC=com,DC=cn",
    "DomainName": "yourDomain.com.cn",
    "DomainDistinguishedName": "DC=yourDomain,DC=com,DC=cn"
}

使用

引用模块

[DependsOn(typeof(AbpLdapModule))]
public class LdapTestModule : AbpModule
{
  
}

注入服务

private readonly ILdapAuthenticateManager _authenticateManager;
public YourApplicationService(ILdapAuthenticateManager authenticateManager)
{
    _authenticateManager = authenticateManager;
}

核心对象

认证 ILdapAuthenticateManager

public interface ILdapAuthenticateManager
{
    /// <summary>
    /// Authenticate 
    /// </summary>
    /// <param name="userDomainName">E.g [email protected] </param>
    /// <param name="password"></param>
    /// <returns></returns>
    bool Authenticate(string userDomainName, string password);
}

组织 ILdapOrganizationManager

public interface ILdapOrganizationManager
{
    /// <summary>
    /// query the specified organizations.
    /// 
    /// filter: (&(ou=xxx)(objectClass=organizationalUnit)) when organizationName is not null
    /// filter: (&(objectClass=organizationalUnit)) when organizationName is null
    /// 
    /// </summary>
    /// <param name="organizationName"></param>
    /// <returns></returns>
    IList<LdapOrganization> GetAll(string organizationName = null);

    /// <summary>
    /// query the specified organization.
    /// 
    /// filter: (&(|(dn=xxx)(distinguishedName=xxx))(objectClass=organizationalUnit)) when organizationName is not null
    /// 
    /// </summary>
    /// <param name="distinguishedName"></param>
    /// <returns></returns>
    LdapOrganization Get(string distinguishedName);
}

用户 ILdapUserManager

public interface ILdapUserManager
{
    /// <summary>
    /// query the specified users.
    /// 
    /// filter: (&(cn=xxx)(objectClass=user)) when userCommonName is not null
    /// filter: (&(objectClass=user)) when userCommonName is null
    /// 
    /// </summary>
    /// <param name="cn"></param>
    /// <returns></returns>
    IList<LdapUser> GetAll(string cn = null);

    /// <summary>
    /// query the specified users.
    /// 
    /// filter: (&((mail=mail)) when mail is not null
    /// 
    /// </summary>
    /// <param name="mail"></param>
    /// <returns></returns>
    IList<LdapUser> GetAllByMail(string mail);

    /// <summary>
    /// query the specified users.
    /// 
    /// filter: (&((sAMAccountName=sAMAccountName)) when sAMAccountName is not null
    /// 
    /// </summary>
    /// <param name="samAccountName"></param>
    /// <returns></returns>
    IList<LdapUser> GetAllBySamAccountName(string samAccountName);

    /// <summary>
    /// query the specified User.
    /// 
    /// filter: (&(dn=xxx)(objectCategory=person)(objectClass=user)) when dn is not null
    /// 
    /// </summary>
    /// <param name="dn"></param>
    /// <returns></returns>
    LdapUser Get(string dn);

}

更多

请参考单元测试

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.