hbehr-AdAuthentication 1.6.1

Plugin for easy Active Directory integration with your ASP.NET project. Works with both Windows Authentication or you can make the user login using his Windows User.
(Only Works in IntraNet App).
Supports pagination

Install-Package hbehr-AdAuthentication -Version 1.6.1
dotnet add package hbehr-AdAuthentication --version 1.6.1
<PackageReference Include="hbehr-AdAuthentication" Version="1.6.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add hbehr-AdAuthentication --version 1.6.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

hbehr.AdAuthentication

Implements Ad authenticator for asp.net, fast and convenient. Can be used with windows authentication and login / password.

Implementa autenticador Ad para asp.net, rápido e prático. Pode ser usado com windows authentication ou login/senha.

Instalation

Get it on nuget: https://www.nuget.org/packages/hbehr-AdAuthentication/

PM> Install-Package hbehr-AdAuthentication

How to use

Create a new instance of the class

Criar uma nova instância da classe

AdAuthenticator adAuthenticator = new AdAuthenticator();

Configure in code

Configurar pelo código,

string ldapPath = "LDAP://DC=radixengrj,DC=matriz";
string ldapDomain = "radixengrj";
adAuthenticator
	.ConfigureSetLdapPath(ldapPath)
	.ConfigureLdapDomain(ldapDomain);

Configure in .config, just add the folowing keys to the LdapPath/Domain

Configurar pelo .config adicionar as chaves para o LdapPath/Domain

<configuration>
  <appSettings>
    <add key="LdapPath" value="LDAP://DC=radixengrj,DC=matriz" />
    <add key="LdapDomain" value="radixengrj" />
  </appSettings>
</configuration>

If you are using Windows Authentication, to fetch the user using the system:

Se estiver usando windows Authentication, para buscar o usuário que está usando o sistema:

AdUser adUser = adAuthenticator.GetUserFromAd();

If you want to authenticate via login / password, use the function:

Caso queira autenticar via login/senha, usar a função:

string login = "henrique.behr";
string password = "*******";
AdUser adUser = adAuthenticator.SearchUserBy(login, password);

If you want to search an user in the AD using the login:

Para buscar um usuário no AD pelo login:

string login = "henrique.behr"
AdUser adUser = adAuthentication.GetUserFromAdBy(login);

Search for all users or groups in the AD:

Buscar por todos os usuários ou grupos do AD

IEnumerable<AdGroup> groups = adAuthenticator.GetAdGroups();
IEnumerable<AdUser> users = adAuthenticator.GetAllUsers();

Filter Users in the AD, either by Username or Name (paginated):

Filtrar usuários no AD, pode ser por login ou nome (paginado).

int page = 1, rowsPerPage = 20, total;
IEnumerable<AdUser> users = adAuthenticator.GetUsersByFilter("hen", page, out total, rowsPerPage); // By Username
users = ad.GetUsersByNameFilter("Behr", page, out total, rowsPerPage); // By Name

Supports method-chain :

Suporta method-chain:

string ldapPath = "LDAP://DC=radixengrj,DC=matriz";
string ldapDomain = "radixengrj";
AdUser adUser = new AdAuthenticator()
	.ConfigureSetLdapPath(ldapPath)
	.ConfigureLdapDomain(ldapDomain)
	.GetUserFromAd();

##Data Structure

User Ad:

Usuário Ad

public class AdUser
{
	public string Name { get; private set; }
	public string Login { get; private set; }
	public string Mail { get; private set; }
	public string Phone { get; private set; }
	public string Company { get; private set; }
	public IEnumerable<AdGroup> AdGroups { get; private set; }
}

Ad Groups:

Grupos Ad

public class AdGroup
{
	public string Code { get; set; }
	public string Name { get; set; }
}
Error Types

The exceptions thrown are of type: AdException, they come with an identification AdError errors that are treated include:

As exceções lançadas são do tipo: AdException, elas vem com uma identificação AdError os erros que são tratados incluem:

     Generic Error *not detected*
     InvalidLdapDomain * Invalid Ldap Domain, verify network configuration *
     UserNotFound * Login user not found in AD *
     IncorrectPassword * Login found but incorrect password *
     ExpiredPassword * User password Expired *
     UserMustResetPassword 
     NotPermittedToLogonAtThisTime
     NotPermittedToLogonAtThisWorkstation
     AccountDisabled
     UserNotGrantedRequestedLogonType
     AccountExpired
     AccountLocked

hbehr.AdAuthentication

Implements Ad authenticator for asp.net, fast and convenient. Can be used with windows authentication and login / password.

Implementa autenticador Ad para asp.net, rápido e prático. Pode ser usado com windows authentication ou login/senha.

Instalation

Get it on nuget: https://www.nuget.org/packages/hbehr-AdAuthentication/

PM> Install-Package hbehr-AdAuthentication

How to use

Create a new instance of the class

Criar uma nova instância da classe

AdAuthenticator adAuthenticator = new AdAuthenticator();

Configure in code

Configurar pelo código,

string ldapPath = "LDAP://DC=radixengrj,DC=matriz";
string ldapDomain = "radixengrj";
adAuthenticator
	.ConfigureSetLdapPath(ldapPath)
	.ConfigureLdapDomain(ldapDomain);

Configure in .config, just add the folowing keys to the LdapPath/Domain

Configurar pelo .config adicionar as chaves para o LdapPath/Domain

<configuration>
  <appSettings>
    <add key="LdapPath" value="LDAP://DC=radixengrj,DC=matriz" />
    <add key="LdapDomain" value="radixengrj" />
  </appSettings>
</configuration>

If you are using Windows Authentication, to fetch the user using the system:

Se estiver usando windows Authentication, para buscar o usuário que está usando o sistema:

AdUser adUser = adAuthenticator.GetUserFromAd();

If you want to authenticate via login / password, use the function:

Caso queira autenticar via login/senha, usar a função:

string login = "henrique.behr";
string password = "*******";
AdUser adUser = adAuthenticator.SearchUserBy(login, password);

If you want to search an user in the AD using the login:

Para buscar um usuário no AD pelo login:

string login = "henrique.behr"
AdUser adUser = adAuthentication.GetUserFromAdBy(login);

Search for all users or groups in the AD:

Buscar por todos os usuários ou grupos do AD

IEnumerable<AdGroup> groups = adAuthenticator.GetAdGroups();
IEnumerable<AdUser> users = adAuthenticator.GetAllUsers();

Filter Users in the AD, either by Username or Name (paginated):

Filtrar usuários no AD, pode ser por login ou nome (paginado).

int page = 1, rowsPerPage = 20, total;
IEnumerable<AdUser> users = adAuthenticator.GetUsersByFilter("hen", page, out total, rowsPerPage); // By Username
users = ad.GetUsersByNameFilter("Behr", page, out total, rowsPerPage); // By Name

Supports method-chain :

Suporta method-chain:

string ldapPath = "LDAP://DC=radixengrj,DC=matriz";
string ldapDomain = "radixengrj";
AdUser adUser = new AdAuthenticator()
	.ConfigureSetLdapPath(ldapPath)
	.ConfigureLdapDomain(ldapDomain)
	.GetUserFromAd();

##Data Structure

User Ad:

Usuário Ad

public class AdUser
{
	public string Name { get; private set; }
	public string Login { get; private set; }
	public string Mail { get; private set; }
	public string Phone { get; private set; }
	public string Company { get; private set; }
	public IEnumerable<AdGroup> AdGroups { get; private set; }
}

Ad Groups:

Grupos Ad

public class AdGroup
{
	public string Code { get; set; }
	public string Name { get; set; }
}
Error Types

The exceptions thrown are of type: AdException, they come with an identification AdError errors that are treated include:

As exceções lançadas são do tipo: AdException, elas vem com uma identificação AdError os erros que são tratados incluem:

     Generic Error *not detected*
     InvalidLdapDomain * Invalid Ldap Domain, verify network configuration *
     UserNotFound * Login user not found in AD *
     IncorrectPassword * Login found but incorrect password *
     ExpiredPassword * User password Expired *
     UserMustResetPassword 
     NotPermittedToLogonAtThisTime
     NotPermittedToLogonAtThisWorkstation
     AccountDisabled
     UserNotGrantedRequestedLogonType
     AccountExpired
     AccountLocked

Release Notes

Added support for 4.0 till 4.7 .Net Framework
Added support for .Net 4.7

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.6.1 1,967 11/29/2017
1.6.0 540 2/4/2017
1.5.1 984 3/12/2016
1.4.2 508 2/1/2016
1.4.1 383 1/14/2016
1.3.3 537 8/3/2015