Open Source Web Application Framework for ASP.NET Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Halil İbrahim Kalkan e849921f7e Resolved #3328: Allow to subscribe to exceptions handled by the abp framework 6 years ago
..
Volo/Abp/Ldap Resolved #3328: Allow to subscribe to exceptions handled by the abp framework 6 years ago
FodyWeavers.xml Remove ConfigureAwait of async method. 6 years ago
FodyWeavers.xsd Add configureawait.props & FodyWeavers.xml & FodyWeavers.xsd. 6 years ago
Volo.Abp.Ldap.csproj Add configureawait.props & FodyWeavers.xml & FodyWeavers.xsd. 6 years ago
readme.md Fix SSL casing. 7 years ago

readme.md

Volo.Abp.Ldap

Only Authenticate(not read/write AD)

Configure

add section in appsettings.json

use SSL

"LDAP": {
    "ServerHost": "192.168.101.54", 
    "ServerPort": 636,
    "UseSsl": true
}

not use SSL

"LDAP": {
    "ServerHost": "192.168.101.54", 
    "ServerPort": 389,
    "UseSsl": false
}

Authenticate

Injecting ILdapManager into a class. For example:

public class TaxAppService : ApplicationService
{
    private readonly ILdapManager _ldapManager;

    public TaxAppService(ILdapManager ldapManager)
    {
        _ldapManager = ldapManager;
    }

    public void Authenticate(string userName, string password)
    { 
        var result = _ldapManager.Authenticate(userName, password);
    }
}

Read/Write AD

Configure

use SSL

"LDAP": {
    "ServerHost": "192.168.101.54",
    "ServerPort": 636,
    "UseSsl": true,
    "Credentials": {
        "DomainUserName": "administrator@yourdomain.com.cn",
        "Password": "yH.20190528"
    },
    "SearchBase": "DC=yourdomain,DC=com,DC=cn",
    "DomainName": "yourdomain.com.cn",
    "DomainDistinguishedName": "DC=yourdomain,DC=com,DC=cn"
}

not use SSL

"LDAP": {
    "ServerHost": "192.168.101.54",
    "ServerPort": 389,
    "UseSsl": false,
    "Credentials": {
        "DomainUserName": "administrator@yourdomain.com.cn",
        "Password": "yH.20190528"
    },
    "SearchBase": "DC=yourdomain,DC=com,DC=cn",
    "DomainName": "yourdomain.com.cn",
    "DomainDistinguishedName": "DC=yourdomain,DC=com,DC=cn"
}
  • Credentials:DomainUserName a administrator of AD.

  • Credentials:Password the password for the administrator.

  • SearchBase: where search from AD.

  • DomainName: name of you domain. no need www.

  • DomainDistinguishedName: distinguished name of root domain.

Query Organizations

// query all organizations
// filter: (&(objectClass=organizationalUnit)) 
_ldapManager.GetOrganizations();

// query organizations by name
// filter: (&(name=abc)(objectClass=organizationalUnit))
_ldapManager.GetOrganizations("abc");

Query Organization

// query organization by distinguished name
// filter: (&(distinguishedName=abc)(objectClass=organizationalUnit))
_ldapManager.GetOrganization("abc");

Add Organization

// use LdapOrganization
_ldapManager.AddSubOrganization("nameA", parentOrganization);

// or use OrganizationDistinguishedName
_ldapManager.AddSubOrganization("nameA", "OU=Domain Controllers,DC=yourdomain,DC=com,DC=cn");

Query Users

// query all users
// filter: (&(objectCategory=person)(objectClass=user))
_ldapManager.GetUsers();

// query organizations by name
// filter: (&(name=abc)(objectCategory=person)(objectClass=user))
_ldapManager.GetUsers(name : "abc");

// query organizations by displayName
// filter: (&(displayName=abc)(objectCategory=person)(objectClass=user))
_ldapManager.GetUsers(displayName : "abc");

// query organization by commonName
// filter: (&(cn=abc)(objectCategory=person)(objectClass=user))
_ldapManager.GetUsers(commonName : "abc");

Query User

// query a user by distinguished name
// filter: (&(distinguishedName=abc)(objectCategory=person)(objectClass=user))
_ldapManager.GetUser("abc");

Add User

// use LdapOrganization
_ldapManager.AddUserToOrganization("nameA", "passwordA", parentOrganization);

// or use OrganizationDistinguishedName
_ldapManager.AddUserToOrganization("nameA", "passwordA", "OU=Domain Controllers,DC=yourdomain,DC=com,DC=cn");

More

See unit test