Buscar outro CustomerID do LDAP

Post Reply
ricardobarrosozcr
Znuny newbie
Posts: 13
Joined: 19 Jul 2013, 20:25
Znuny Version: 3.2.9
Real Name: Ricardo Barroso
Company: ZCR

Buscar outro CustomerID do LDAP

Post by ricardobarrosozcr »

Pessoal, boa tarde.
Estou começando a utilizar o OTRS agora e já tenhoo muitas duvidas. Primeiro gostaria de parabenizar a todos pelo forum, muito ativo e útil, já me ajudou.

Estou com uma dúvida agora quanto ao CustomerID. O meu OTRS busca os clientes no AD do Windows Server 2008 R2. Fiz a configuração toda no arquivo Config.pm.
Notei que ele alimenta as propriedades do cliente baseado nas propriedades do AD. Assim o campo ID do Cliente é preenchido com o atributo 'mail' do usuário do LDAP.

Eu gostaria de mudar para que ele preencha o campo ID do Cliente com o atributo 'company' do LDAP onde eu vou preencher com o nosso CNPJ pois usamos o OTRS para clintes internos e externos.

Segue meu Config.pm:

# --
# Kernel/Config.pm - Config file for OTRS kernel
# Copyright (C) 2001-2013 xxx, http://otrs.org/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
# Note:
#
# -->> Most OTRS configuration should be done via the OTRS web interface
# and the SysConfig. Only for some configuration, such as database
# credentials and customer data source changes, you should edit this
# file. For changes do customer data sources you can copy the definitions
# from Kernel/Config/Defaults.pm and paste them in this file.
# Config.pm will not be overwritten when updating OTRS.
# --

package Kernel::Config;

use strict;
use warnings;
use utf8;

sub Load {
my $Self = shift;

# ---------------------------------------------------- #
# database settings #
# ---------------------------------------------------- #

# The database host
$Self->{'DatabaseHost'} = 'localhost';

# The database name
$Self->{'Database'} = 'otrs';

# The database user
$Self->{'DatabaseUser'} = 'otrs';

# The password of database user. You also can use bin/otrs.CryptPassword.pl
# for crypted passwords
$Self->{'DatabasePw'} = 'it@c@re43@';

# The database DSN for MySQL ==> more: "perldoc DBD::mysql"
$Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";

# The database DSN for PostgreSQL ==> more: "perldoc DBD::Pg"
# if you want to use a local socket connection
# $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};";
# if you want to use a TCP/IP connection
# $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};host=$Self->{DatabaseHost};";
# if you have PostgresSQL 8.1 or earlier, activate the legacy driver with this line:
# $Self->{DatabasePostgresqlBefore82} = 1;

# The database DSN for Microsoft SQL Server - only supported if OTRS is
# installed on Windows as well
# $Self->{DatabaseDSN} = "DBI:ODBC:driver={SQL Server};Database=$Self->{Database};Server=$Self->{DatabaseHost},1433";

# The database DSN for Oracle ==> more: "perldoc DBD::oracle"
# $ENV{ORACLE_HOME} = '/u01/app/oracle/product/10.2.0/client_1';
# $ENV{NLS_DATE_FORMAT} = 'YYYY-MM-DD HH24:MI:SS';
# $ENV{NLS_LANG} = "american_america.utf8";

# $Self->{DatabaseDSN} = "DBI:Oracle:sid=OTRS;host=$Self->{DatabaseHost};port=1522;";

# ---------------------------------------------------- #
# fs root directory
# ---------------------------------------------------- #
$Self->{Home} = '/opt/otrs';



# ---------------------------------------------------- #
# insert your own config settings "here" #
# config settings taken from Kernel/Config/Defaults.pm #
# ---------------------------------------------------- #
# $Self->{SessionUseCookie} = 0;
# $Self->{CheckMXRecord} = 0;

# ---------------------------------------------------- #

# ---------------------------------------------------- #
# data inserted by installer #
# ---------------------------------------------------- #
# $DIBI$

# ---------------------------------------------------- #
# ---------------------------------------------------- #
# #
# end of your own config options!!! #
# #
# ---------------------------------------------------- #
# ---------------------------------------------------- #


#Autenticação LDAP #Enable para os clientes / usuários
$Self->{'Customer::AuthModule'} = 'Kernel::System::CustomerAuth::LDAP';
$Self->{'Customer::AuthModule::LDAP::Host'} = 'srv-dc00.zcr.com.br';
$Self->{'Customer::AuthModule::LDAP::BaseDN'} = 'ou=SEDE,dc=zcr,dc=com,dc=br';
$Self->{'Customer::AuthModule::LDAP::UID'} = 'sAMAccountName';

# O seguinte é válido, mas somente seria necessário se o
# usuário anônimo não tem permissão para ler da árvore LDAP
$Self->{'Customer::AuthModule::LDAP::SearchUserDN'} = 'otrs';
$Self->{'Customer::AuthModule::LDAP::SearchUserPw'} = 'senha;

#CustomerUser
#(cliente backend de banco de dados de usuário e configurações)
$Self->{CustomerUser} = {
Module => 'Kernel::System::CustomerUser::LDAP',
Params => {
port => '389',
timeout => '120',
async => '0',
version => '3',
Host => 'srv-dc00.zcr.com.br',
BaseDN => 'ou=SEDE,dc=zcr,dc=com,dc=br',
SSCOPE => 'sub',
UserDN =>'otrs',
UserPw => 'senha',
},
# customer unique id
CustomerKey => 'sAMAccountName',
# customer #
CustomerID => 'company',
CustomerUserListFields => ['sAMAccountName', 'cn', 'mail' , 'company'],
CustomerUserSearchFields => ['sAMAccountName', 'cn', 'mail' , 'company'],
CustomerUserSearchPrefix => '',
CustomerUserSearchSuffix => '*',
CustomerUserSearchListLimit => 250,
CustomerUserPostMasterSearchFields => ['mail'],
CustomerUserNameFields => ['givenname', 'sn'],
Map => [
# note: Login, Email and CustomerID needed!
# var, frontend, storage, shown, required, storage-type
#[ 'UserSalutation', 'Title', 'title', 1, 0, 'var' ],
[ 'UserFirstname', 'Firstname', 'givenname', 1, 1, 'var' ],
[ 'UserLastname', 'Lastname', 'sn', 1, 1, 'var' ],
[ 'UserLogin', 'Login', 'sAMAccountName', 1, 1, 'var' ],
[ 'UserEmail', 'Email', 'mail', 1, 1, 'var' ],
[ 'UserCustomerID', 'CustomerID', 'mail', 0, 1, 'var' ],
[ 'UserPhone', 'Phone', 'telephonenumber', 1, 0, 'var' ],
#[ 'UserAddress', 'Address', 'postaladdress', 1, 0, 'var' ],
#[ 'UserComment', 'Comment', 'description', 1, 0, 'var' ],
],
};

#Add the following lines when only users are allowed to login if they reside in the spicified security group
#Remove these lines if you want to provide login to all users specified in the User Base DN
#example: $Self->{'Customer::AuthModule::LDAP::BaseDN'} = 'ou=BaseOU, dc=example, dc=com';
$Self->{'Customer::AuthModule::LDAP::GroupDN'} = 'CN=GR-ZCR-OTRS-Clientes,OU=Grupos,OU=SEDE,DC=zcr,DC=com,DC=br';
$Self->{'Customer::AuthModule::LDAP::AccessAttr'} = 'member';
$Self->{'Customer::AuthModule::LDAP::UserAttr'} = 'DN'
}

# ---------------------------------------------------- #
# needed system stuff (don't edit this) #
# ---------------------------------------------------- #
use strict;
use warnings;

use vars qw(@ISA);

use Kernel::Config::Defaults;
push (@ISA, 'Kernel::Config::Defaults');

# -----------------------------------------------------#

1;
thiagopachecoit
Znuny newbie
Posts: 14
Joined: 26 Aug 2012, 16:01
Znuny Version: 5.0.x
Real Name: Thiago Pacheco
Company: Unirede Soluções Corporativas

Re: Buscar outro CustomerID do LDAP

Post by thiagopachecoit »

Olá Ricardo,


Você precisa alterar o atributo abaixo :

CustomerUserPostMasterSearchFields => ['mail'],


Para o novo atributo:

CustomerUserPostMasterSearchFields => ['company'],


Claro você precisa ter certeza de usar o nome do atributo corretamente.
--

Thiago Pacheco
ITSM Consulting

- PMP
- ITIL V2 Manager / ITIL V3 Expert
- LPI 1,2,3
Utilizador de OTRS 5, OTRS 4, OTRS 3.3.X, OTRS 3.2.X, OTRS 3.1.X
ricardobarrosozcr
Znuny newbie
Posts: 13
Joined: 19 Jul 2013, 20:25
Znuny Version: 3.2.9
Real Name: Ricardo Barroso
Company: ZCR

Re: Buscar outro CustomerID do LDAP

Post by ricardobarrosozcr »

Obrigado Thiago,
fiz a configuração do config.pm como voce informou e funcionou tranquilo.
estomagado
Znuny newbie
Posts: 44
Joined: 20 Sep 2019, 16:24
Znuny Version: 6.0.36
Real Name: Henrique Ulbrich
Company: Design for Context

Re: Buscar outro CustomerID do LDAP

Post by estomagado »

Este é um post antigo, mas posso confirmar que estava tendo o mesmo problema e foi resolvido com a solução mostrada aqui. Meu OTRS 6.0.18.
thiagopachecoit wrote: 22 Jul 2013, 22:02 Você precisa alterar o atributo abaixo :
CustomerUserPostMasterSearchFields => ['mail'],

Para o novo atributo:
CustomerUserPostMasterSearchFields => ['company'],
Depois que fiz isso, funcionou!
Detalhe, não achei essa informação no fórum geral em inglês, mas encontrei aqui.
--
Your pal
Estomagado

Znuny 6.0.36 Vanilla (no add-ons installed, no fancy customization)
MySQL BD backend for external customer users
LDAP (AD) backend for internal customer users & agents
Post Reply