Update otrs to Znuny - ldap Config.pm

Moderator: crythias

Post Reply
Manfred89
Znuny newbie
Posts: 53
Joined: 14 Jun 2023, 21:44
Znuny Version: 6.5.8
Real Name: Manfred

Update otrs to Znuny - ldap Config.pm

Post by Manfred89 »

Hey guys,

Znuny:6.5.3 (and tested with 6.0.48 and otrs 5.0.42)
Debian 11.4

I have been trying to do an LDAP connection so that several hundred users in the customer.pl can log into the system without me having to create the accounts myself.

I set up a server free and copied the config.pm from a working ticket system. Also I have a second server (clone of the working system - OTRS 5.0.42) the Config.pm inside, this works until the Znuny update, after that not anymore.

Normally I would have to copy the /opt/otrs/Kernel/Config.pm from the working server and paste it or the following content:
(private settings of course hidden)

Code: Select all

# --
# Kernel/Config.pm - Config file for OTRS kernel
# Copyright (C) 2001-2015 xxx, http://otrs.com/
# --
# 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'} = '127.0.0.1';

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

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

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

    # 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};";

    # 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"
#    $Self->{DatabaseDSN} = "DBI:Oracle://$Self->{DatabaseHost}:1521/$Self->{Database}";
#
#    $ENV{ORACLE_HOME}     = '/path/to/your/oracle';
#    $ENV{NLS_DATE_FORMAT} = 'YYYY-MM-DD HH24:MI:SS';
#    $ENV{NLS_LANG}        = 'AMERICAN_AMERICA.AL32UTF8';

    # ---------------------------------------------------- #
    # 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$
# CustomerUser
# (customer ldap backend and settings)
$Self->{CustomerUser} = {
    Name => 'LDAP Datenbank',
    Module => 'Kernel::System::CustomerUser::LDAP',
    Params => {
        # ldap host
        Host => 'ldaps://xxxxx.de',
        # ldap base dn
        BaseDN => 'o=xxxx',
        # search scope (one|sub)
        SSCOPE => 'sub',
        sizelimit => 0,
        # The following is valid but would only be necessary if the
        # anonymous user does NOT have permission to read from the LDAP tree
        UserDN => 'cn=xxxxx,ou=xxx,o=xxxxx',
        UserPw => 'xxxxxx',
        # in case you want to add always one filter to each ldap query, use
        # this option. e. g. AlwaysFilter => '(mail=*)' or AlwaysFilter => '(objectclass=user)'
        AlwaysFilter => '',
            # if both your frontend and your LDAP are unicode, use this:
            SourceCharset => 'utf-8',
            DestCharset   => 'utf-8',
            # if your frontend is unicode and the charset of your
            # ldap server is iso-8859-1, use these options.
            # SourceCharset => 'iso-8859-1',
            # DestCharset => 'utf-8',
            # Net::LDAP new params (if needed - for more info see perldoc Net::LDAP)
            Params => {
                port => 636,
                timeout => 600,
                async => 0,
                version => 3,
            },
    },
    # customer unique id
    CustomerKey => 'cn',
    # customer #
    CustomerID => 'cn',
    CustomerUserListFields => ['givenname', 'sn', 'mail'],
    CustomerUserSearchFields => ['uid', 'cn', 'mail', 'givenname', 'sn', 'xxxxmailPreferredAddress'],
    CustomerUserSearchPrefix => '',
    CustomerUserSearchSuffix => '*',
    CustomerUserSearchListLimit => 150000,
    CustomerUserPostMasterSearchFields => ['xxxxmailPreferredAddress', 'mail', 'cn', 'sn'],
    CustomerUserNameFields => ['givenname', 'sn'],
    # show not own tickets in customer panel, CompanyTickets
    CustomerUserExcludePrimaryCustomerID => 0,
    # add an ldap filter for valid users (expert setting)
#    CustomerUserValidFilter => '(!(description=locked))',
    # administrator can't change customer preferences
    AdminSetPreferences => 0,
#    # cache time to live in sec. - cache any database queries
#    CacheTTL => 0,
    Map => [
        # note: Login, Email and CustomerID are mandatory!
        # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
        [ 'UserFirstname',  'Firstname',  'givenname',       1, 1, 'var', '', 0 ],
        [ 'UserLastname',   'Lastname',   'sn',              1, 1, 'var', '', 0 ],
        [ 'UserLogin',      'Username',   'cn',             1, 1, 'var', '', 0 ],
        [ 'UserEmail',      'Email',      'xxxxmailPreferredAddress',            1, 1, 'var', '', 0 ],
        [ 'UserCustomerID', 'CustomerID', 'cn',            0, 1, 'var', '', 0 ],
#        [ 'UserCustomerIDs', 'CustomerIDs', 'second_customer_ids', 1, 0, 'var', '', 0 ],
#        [ 'UserPhone',      'Phone',      'telephonenumber', 1, 0, 'var', '', 0 ],
#        [ 'UserAddress',    'Address',    'postaladdress',   1, 0, 'var', '', 0 ],
#        [ 'UserComment',    'Comment',    'description',     1, 0, 'var', '', 0 ],
    ],
};
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
    #                                                      #
    # end of your own config options!!!                    #
    #                                                      #
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
}

Now when I try to log in with the ldap user, the message "Login failed! Username or password entered incorrectly."
  • Thought I'd look in the /var/log/syslog, but no entry is found there
  • With nmap "ldap server" ldap and ldapssl are "STATE: Open"
  • Server restart didn't do anything either

It doesn't seem to change any settings in the frontend. WIe said, there is an existing successful config from another server.
Do I still need to change settings somewhere?

following hints:
  • The LDAP settings only take effect when I enter it in the frontend
e.g.:
-> "Customer::Auth"
- Customer::AuthModule: Kernel::System::CustomerAuth::LDAP
- Customer::AuthModule::LDAP::BaseDN: o=xxxxx
- Customer::AuthModule::LDAP::Die: Disabled
- Customer::AuthModule::LDAP::Host: ldaps://xxxx.de
- Customer::AuthModule::LDAP::Params: port: 636, timeout: 120, version 3, async 0
- Customer::AuthModule::LDAP::SearchUserDN: cn=xxxxx,ou=xxxx,o=xx-xxxx
- Customer::AuthModule::LDAP::SearchUserPw: xxxxxxx
- Customer::AuthModule::LDAP::UID: cn
- Customer::AuthModule::Radius::Die: disabled

After that I can login to the customer.pl area in the frontend.

If I change something in the Config.pm afterwards, I can't log in via LDAP anymore, unless I set the setting correctly again.
If I change something in the Config.pm, the setting is not displayed/sync in the frontend.
root
Administrator
Posts: 3968
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Update otrs to Znuny - ldap Config.pm

Post by root »

Hi,

Since you do not have your CustomerAuth settings in the Kernel/Config.pm (for whatever reason), you need to change them via System Configuration. I always recommend having them in the Kernel/Config.pm and via System Configuration.

Without knowing what you change in the Config.pm after it worked no one can tell you what the problem is.

- Roy


P.S.: The code hasn't changed in years for this: https://github.com/znuny/Znuny/blame/re ... th/LDAP.pm
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Manfred89
Znuny newbie
Posts: 53
Joined: 14 Jun 2023, 21:44
Znuny Version: 6.5.8
Real Name: Manfred

Re: Update otrs to Znuny - ldap Config.pm

Post by Manfred89 »

Hey Roy,

thank you very much for your answer.

I did not change anything in Config.pm after the update or even on my other system.

The entries (on the working system) were already so when I looked at the system the 1st time.

So were the settings in the Config.pm incorrect from the beginning by "CustomerUser" instead of "CustomerAuth" and my colleague (who is no longer there) activated it via the frontend)?
root
Administrator
Posts: 3968
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Update otrs to Znuny - ldap Config.pm

Post by root »

Hi,

That's what you wrote, sounds like you changed something too me:
Manfred89 wrote: 20 Oct 2023, 14:11 If I change something in the Config.pm afterwards, I can't log in via LDAP anymore, unless I set the setting correctly again.
Manfred89 wrote: 20 Oct 2023, 14:11 So were the settings in the Config.pm incorrect from the beginning by "CustomerUser" instead of "CustomerAuth" and my colleague (who is no longer there) activated it via the frontend)?
It's no instead, it's both. CustomerUser is the data source for the customer user, and CustomerAuth relates to the authentication.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Manfred89
Znuny newbie
Posts: 53
Joined: 14 Jun 2023, 21:44
Znuny Version: 6.5.8
Real Name: Manfred

Re: Update otrs to Znuny - ldap Config.pm

Post by Manfred89 »

Thank you very much Roy,

you have put me on the right track.

I always thought that the CustomerUser must be the only necessary setting in the Config.pm file for LDAP authentication. I relied so much on the Config.pm from the predecessor, so I never questioned the Customer::AUTHModule.


Have now tested everything with the AuthModule and now the same settings are inside (via the Config.pm) as in the working system with the note that the data were adjusted via the Config.pm and are not changeable in the SysConfig!

Then my predecessor has set all this via the Sysconfig?!

piece by piece I get a puzzle piece put together by the ticket system :)

Thx!
Post Reply