hbehr-AdAuthentication 1.6.1

dotnet add package hbehr-AdAuthentication --version 1.6.1                
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.
<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 and Polyglot Notebooks. 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 Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 6,478 11/29/2017
1.6.0 1,671 2/4/2017
1.5.1 7,270 3/12/2016
1.4.2 1,358 2/1/2016
1.4.1 1,450 1/14/2016
1.3.3 2,220 8/3/2015

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