Adds an attributes parameter to the ldap adapter (#184)

* Adds an attribute parameter to the ldap adapter

Using this parameter is much more efficient than the default action (which is to return all attributes and their associated values). The use of this parameter should therefore be considered good practice.

(from https://www.php.net/manual/en/function.ldap-search.php)

* Updates the docs about ldap_attributes parameter

* Enhances portuguese translation

* Update backend/Services/Auth/Adapters/LDAP.php

Commit suggestion
This commit is contained in:
Luiz Kill 2021-02-18 05:18:30 -03:00 committed by GitHub
parent 55f3dd1a5f
commit a48fa3c717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 23 deletions

View File

@ -30,6 +30,7 @@ class LDAP implements Service, AuthInterface
protected $ldap_bindPass;
protected $ldap_baseDN;
protected $ldap_filter;
protected $ldap_attributes;
protected $ldap_userFieldMapping;
public function __construct(Session $session)
@ -52,6 +53,7 @@ class LDAP implements Service, AuthInterface
$this->ldap_bindPass = $config['ldap_bindPass'];
$this->ldap_baseDN = $config['ldap_baseDN'];
$this->ldap_filter = $config['ldap_filter'];
$this->ldap_attributes = isset($config['ldap_attributes']) ? $config['ldap_attributes'] : ['*'];
$this->ldap_userFieldMapping = $config['ldap_userFieldMapping'];
}else {
@ldap_close($connect);
@ -166,7 +168,7 @@ class LDAP implements Service, AuthInterface
if (!$ldapBind) throw new \Exception('Cannot Bind to LDAP server: Wrong credentials?');
// search the LDAP server for users
$ldapSearch = @ldap_search($ldapConn, $this->ldap_baseDN, $this->ldap_filter, ['*']);
$ldapSearch = @ldap_search($ldapConn, $this->ldap_baseDN, $this->ldap_filter, $this->ldap_attributes);
$ldapResults = @ldap_get_entries($ldapConn, $ldapSearch);
@ldap_close($ldapConn);

View File

@ -100,6 +100,7 @@ Replace your current Auth handler in `configuration.php` file like this:
'ldap_bindPass'=>'ldapbinduser-password',
'ldap_baseDN'=>'cn=users,dc=ldap,dc=example,dc=com',
'ldap_filter'=>'(uid=*)', //ex: 'ldap_filter'=>'(&(uid=*)(memberOf=cn=administrators,cn=groups,dc=ldap,dc=example,dc=com))',
'ldap_attributes' => ["uid","cn","dn"],
'ldap_userFieldMapping'=> [
'username' =>'uid',
'name' =>'cn',

View File

@ -1,16 +1,16 @@
const data = {
'Selected': 'Selecionado: {0} de {1}',
'Uploading files': 'Fazendo o upload {0}% de {1}',
'File size error': '{0} é muito grande, por favor faça o upload de arquivos menores do que {1}',
'File size error': '{0} é muito grande, por favor faça upload de arquivos menores que {1}',
'Upload failed': '{0} falhou ao fazer o upload',
'Per page': '{0} Por Página',
'Folder': 'Pasta',
'Login failed, please try again': 'Login falhou, por favor tente novamente.',
'Already logged in': 'Já está logado.',
'Please enter username and password': 'Por favor entre com o nome de usuário e senha.',
'Not Found': 'Não Encontrado',
'Not Allowed': 'Não Autorizado',
'Please log in': 'Por favor, faça o login',
'Per page': '{0} Por página',
'Folder': 'Diretório',
'Login failed, please try again': 'Login falhou, por favor tente novamente',
'Already logged in': 'Já está logado',
'Please enter username and password': 'Por favor entre com o nome de usuário e a senha',
'Not Found': 'Não encontrado',
'Not Allowed': 'Não autorizado',
'Please log in': 'Por favor faça o login',
'Unknown error': 'Erro desconhecido',
'Add files': 'Adicionar arquivos',
'New': 'Novo',
@ -20,8 +20,8 @@ const data = {
'Login': 'Entrar',
'Logout': 'Sair',
'Profile': 'Perfil',
'No pagination': 'Sem Paginação',
'Time': 'Tempo',
'No pagination': 'Sem paginação',
'Time': 'Data',
'Name': 'Nome',
'Size': 'Tamanho',
'Home': 'Página inicial',
@ -30,7 +30,7 @@ const data = {
'Rename': 'Renomear',
'Required': 'Por favor preencha este campo',
'Zip': 'Comprimir',
'Batch Download': 'Download em lotes',
'Batch Download': 'Download em lote',
'Unzip': 'Descomprimir',
'Delete': 'Deletar',
'Download': 'Download',
@ -39,12 +39,12 @@ const data = {
'File': 'Arquivo',
'Drop files to upload': 'Arraste arquivos para fazer o upload',
'Close': 'Fechar',
'Select Folder': 'Selecionar Pasta',
'Select Folder': 'Selecionar diretório',
'Users': 'Usuários',
'Files': 'Arquivos',
'Role': 'Posição',
'Role': 'Perfil',
'Cancel': 'Cancelar',
'Paused': 'Parado',
'Paused': 'Pausado',
'Confirm': 'Confirmar',
'Create': 'Criar',
'User': 'Usuário',
@ -54,27 +54,27 @@ const data = {
'Write': 'Escrever',
'Upload': 'Upload',
'Permissions': 'Permissões',
'Homedir': 'Pasta da página inicial',
'Homedir': 'Página inicial',
'Leave blank for no change': 'Deixe em branco para não fazer nenhuma alteração',
'Are you sure you want to do this?': 'Tem certeza que deseja fazer isto?',
'Are you sure you want to allow access to everyone?': 'Tem certeza que deseja permitir o acesso a todos?',
'Are you sure you want to stop all uploads?': 'Tem certeza que deseja parar todos os uploads?',
'Something went wrong': 'Algo deu errado',
'Invalid directory': 'Diretório inválido',
'This field is required': 'Este arquivo é obrigatório',
'This field is required': 'Este campo é obrigatório',
'Username already taken': 'O nome de usuário já existe',
'User not found': 'Usuário não encontrado',
'Old password': 'Senha atual',
'New password': 'Nova senha',
'Wrong password': 'Senha inválida',
'Updated': 'Atualizado',
'Deleted': 'Excluido',
'Deleted': 'Excluído',
'Your file is ready': 'Seu arquivo está pronto',
'View': 'View',
'Search': 'Search',
'View': 'Visualizar',
'Search': 'Procurar',
'Download permission': 'Download',
'Guest': 'Guest',
'Show hidden': 'Mostrar oculto',
'Guest': 'Convidado',
'Show hidden': 'Mostrar ocultos',
}
export default data