Sync additional LDAP Fields to OTRS-Agents

Moderator: crythias

Locked
mittfran
Znuny newbie
Posts: 9
Joined: 18 Feb 2013, 15:29
Znuny Version: 3.3.7

Sync additional LDAP Fields to OTRS-Agents

Post by mittfran »

Hey guys,

I managed to add custom fields for my agents which i need for my signatures etc with following code:

Code: Select all

    $Self->{PreferencesGroups}->{UserDepartment} = {
        Module => 'Kernel::Output::HTML::PreferencesGeneric',
        Column => 'Other Settings',
        Label => 'Additional Data',
        Key => 'Department',
        Block => 'Input',
        Data => '$Env{"UserDepartment"}',
        PrefKey => 'UserDepartment',
        Prio => 7000,
        Active => 1,
    };
Is it possible to sync such additional fields with LDAP? I tried to add it in the UserSyncMap, but with no luck.

Code: Select all

    $Self->{'AuthSyncModule::LDAP::UserSyncMap'} = {
        UserFirstname => 'givenName',
        UserLastname => 'sn',
        UserEmail => 'mail',
        UserDepartment => 'department',
    };
Has anybody achieved this?

regards, mittfran
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Sync additional LDAP Fields to OTRS-Agents

Post by crythias »

AuthSync would be for user table which you could alter table to store that, or you can push to preferences which isn't AuthSync.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
mittfran
Znuny newbie
Posts: 9
Joined: 18 Feb 2013, 15:29
Znuny Version: 3.3.7

Re: Sync additional LDAP Fields to OTRS-Agents

Post by mittfran »

I added a "phone" field to the users table in the otrs.

Code: Select all

alter table users add phone varchar(20)
But how do I tell OTRS that there is a phone column an that OTRS should create a var "UserDepartment" with data of the column "phone"?
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Sync additional LDAP Fields to OTRS-Agents

Post by reneeb »

Search the Kernel/Default.pm for the Map where UserEmail etc. are defined...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
mittfran
Znuny newbie
Posts: 9
Joined: 18 Feb 2013, 15:29
Znuny Version: 3.3.7

Re: Sync additional LDAP Fields to OTRS-Agents

Post by mittfran »

Do you mean UserSyncMap?
I already have this in my Config.pm:

Code: Select all

    $Self->{'AuthSyncModule::LDAP::UserSyncMap'} = {
        UserFirstname => 'givenName',
        UserLastname => 'sn',
        UserEmail => 'mail',
        UserPhone => 'telephoneNumber',
    };
I think you have to tell OTRS that there is a UserPhone attribute which isn't default.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Sync additional LDAP Fields to OTRS-Agents

Post by reneeb »

Edit: I was wrong. I had the "customers" in mind, not the agents. Sorry for the noise...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Sync additional LDAP Fields to OTRS-Agents

Post by crythias »

Edit Kernel/System/User.pm
Original:

Code: Select all

    # update db
    return if !$Self->{DBObject}->Do(
        SQL => "UPDATE $Self->{UserTable} SET title = ?, first_name = ?, last_name = ?, "
            . " $Self->{UserTableUser} = ?, valid_id = ?, "
            . " change_time = current_timestamp, change_by = ? "
            . " WHERE $Self->{UserTableUserID} = ?",
        Bind => [
            \$Param{UserTitle}, \$Param{UserFirstname}, \$Param{UserLastname},
            \$Param{UserLogin}, \$Param{ValidID}, \$Param{ChangeUserID}, \$Param{UserID},
        ],
    );
change to

Code: Select all

    # update db
    return if !$Self->{DBObject}->Do(
        SQL => "UPDATE $Self->{UserTable} SET title = ?, first_name = ?, last_name = ?, "
            . " $Self->{UserTableUser} = ?, valid_id = ?, "
            . " change_time = current_timestamp, change_by = ?, phone = ? "
            . " WHERE $Self->{UserTableUserID} = ?",
        Bind => [
            \$Param{UserTitle}, \$Param{UserFirstname}, \$Param{UserLastname},
            \$Param{UserLogin}, \$Param{ValidID}, \$Param{ChangeUserID}, \$Param{UserPhone}, \$Param{UserID}
        ],
    );
This updates phone.

Original:

Code: Select all

    # get initial data
    my @Bind;
    my $SQL = "SELECT $Self->{UserTableUserID}, $Self->{UserTableUser}, "
        . " title, first_name, last_name, $Self->{UserTableUserPW}, valid_id, "
        . " create_time, change_time FROM $Self->{UserTable} WHERE ";
Change to:

Code: Select all

    # get initial data
    my @Bind;
    my $SQL = "SELECT $Self->{UserTableUserID}, $Self->{UserTableUser}, "
        . " title, first_name, last_name, $Self->{UserTableUserPW}, valid_id, "
        . " create_time, change_time, phone FROM $Self->{UserTable} WHERE ";
This gets the phone

Code: Select all

    while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
        $Data{UserID}        = $Row[0];
        $Data{UserLogin}     = $Row[1];
        $Data{UserTitle}     = $Row[2];
        $Data{UserFirstname} = $Row[3];
        $Data{UserLastname}  = $Row[4];
        $Data{UserPw}        = $Row[5];
        $Data{ValidID}       = $Row[6];
        $Data{CreateTime}    = $Row[7];
        $Data{ChangeTime}    = $Row[8];
        $Data{UserPhone}    = $Row[9];
    }
Find and replace within....
Last edited by crythias on 25 Mar 2014, 23:17, edited 1 time in total.
Reason: bad order of fields. Make sure UserID is at the end.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
quarx0
Znuny newbie
Posts: 2
Joined: 30 Aug 2013, 10:01
Znuny Version: 3.2.10
Real Name: Paulo Matias
Company: TAP

Re: Sync additional LDAP Fields to OTRS-Agents

Post by quarx0 »

Hello,

Just stumbled on this thread and it's exactly what I was looking for. Following these instructions I was able to add some more attributes to my users (agents) table from LDAP.

Thank you,
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Sync additional LDAP Fields to OTRS-Agents

Post by crythias »

There's also this: viewtopic.php?f=60&t=19936 which might be better alternative.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
nmuleski
Znuny newbie
Posts: 22
Joined: 17 May 2013, 20:51
Znuny Version: 3.2.6
Real Name: nathan muleski
Company: Palmer Johnson Power Systems

Re: Sync additional LDAP Fields to OTRS-Agents

Post by nmuleski »

I have made the changes to the Users.pm file and added a column to the users database but it still is not populating.

Is it necessary to restart the server after making those changes?
OTRS 3.2.6
Ubuntu Server 12.4.02
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Sync additional LDAP Fields to OTRS-Agents

Post by crythias »

possibly restart apache, but I don't know what you changed, so I can't tell you anything about what's broken.

note

Code: Select all

            . " change_time = current_timestamp, change_by = ?, phone = ? "

Code: Select all

            \$Param{UserLogin}, \$Param{ValidID}, \$Param{ChangeUserID}, \$Param{UserPhone}, \$Param{UserID}
If this isn't populating, it's because there's no Map...
Last edited by crythias on 25 Mar 2014, 23:18, edited 1 time in total.
Reason: bad order of fields. Make sure UserID is at the end.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
nmuleski
Znuny newbie
Posts: 22
Joined: 17 May 2013, 20:51
Znuny Version: 3.2.6
Real Name: nathan muleski
Company: Palmer Johnson Power Systems

Re: Sync additional LDAP Fields to OTRS-Agents

Post by nmuleski »

Sorry, I meant to post that to my thread, not this one.

viewtopic.php?f=62&t=24108

I'll just post this there to avoid any confusion.
OTRS 3.2.6
Ubuntu Server 12.4.02
Locked