Skip to content

Implements Ad authenticator for asp.net, fast and convenient. Can be used with windows authentication or login / password. Implementa autenticador Ad para asp.net, rápido e prático. Pode ser usado com windows authentication ou login/senha.

License

Notifications You must be signed in to change notification settings

henriqb/hbehr.AdAuthentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Implements Ad authenticator for asp.net, fast and convenient. Can be used with windows authentication or login / password. Implementa autenticador Ad para asp.net, rápido e prático. Pode ser usado com windows authentication ou login/senha.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages