hbehr-AdAuthentication 1.6.1

.NET Framework 4.0
NuGet\Install-Package hbehr-AdAuthentication -Version 1.6.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
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
#r "nuget: hbehr-AdAuthentication, 1.6.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install hbehr-AdAuthentication as a Cake Addin
#addin nuget:?package=hbehr-AdAuthentication&version=1.6.1

// Install hbehr-AdAuthentication as a Cake Tool
#tool nuget:?package=hbehr-AdAuthentication&version=1.6.1

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
Product Versions
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.1 5,063 11/29/2017
1.6.0 1,302 2/4/2017
1.5.1 6,165 3/12/2016
1.4.2 1,078 2/1/2016
1.4.1 1,185 1/14/2016
1.3.3 1,923 8/3/2015

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