Custom LDAP sync in Agent Preferences issue

Moderator: crythias

Post Reply
duncan9562
Znuny newbie
Posts: 11
Joined: 23 Feb 2016, 14:51
Znuny Version: 5.0.14
Real Name: Duncan Mountford

Custom LDAP sync in Agent Preferences issue

Post by duncan9562 »

We are using LDAP for user authentication, however I am after getting more fields from AD into Agent preferences.

Currently we sync:-

UserFirstname
UserLastname
UserEmail
UserMobile

...without any issues.

I created a custom field in Agent Preferences using the below .xml (located in /opt/otrs/Kernel/Config/Files/AgentPrefs-myfield.xml):-

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<otrs_config version="1.0" init="Framework">
    <ConfigItem Name="PreferencesGroups###Telephone" Required="0" Valid="1">
        <Description Translatable="1">Agent Telephone Number.</Description>
        <Group>Framework</Group>
        <SubGroup>Frontend::Agent::Preferences</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::Output::HTML::Preferences::Generic</Item>
                <Item Key="Column">Other Settings</Item>
                <Item Key="Label" Translatable="1">Telephone</Item>
                <Item Key="Key" Translatable="1">Telephone</Item>
                <Item Key="Block">Input</Item>
                <Item Key="Data">$Env{"UserMyFieldTelephone"}</Item>
                <Item Key="PrefKey">UserMyFieldTelephone</Item>
                <Item Key="Prio">6100</Item>
                <Item Key="Active">0</Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config> 
This creates the relevant fields in 'Framework → Frontend::Agent::Preferences'. Also, under the Agent Preferences tab (viewing as Agent or Admin) I can see the "UserMyFieldTelephone" input box.

I have checked in the DB, and the preferences_key has been added:-

Code: Select all

mysql> select * from user_preferences where preferences_key="UserMyFieldTelephone";
+---------+----------------------+-------------------+
| user_id | preferences_key      | preferences_value |
+---------+----------------------+-------------------+
|      17 | UserMyFieldTelephone |                   |
+---------+----------------------+-------------------+
1 row in set (0.00 sec)

So, I tried to add the config to sync the attribute "ipPhone" from AD into the newly created Field. We store our AgentAuth config in /opt/otrs/Kernel/Config/Files/ZZZCustomLDAPAgentAuth.pm which now looks like this:-

Code: Select all

    $Self->{'AuthSyncModule::LDAP::UserSyncMap'} = {
        # DB -> LDAP
        UserFirstname => 'givenName',
        UserLastname  => 'sn',
        UserEmail     => 'mail',
        UserMobile    => 'mobile',
        UserMyFieldTelephone => 'ipPhone'
As stated, the other fields such as UserEmail and UserMobile all sync OK, and when changed in AD the changes are reflected on next log in to OTRS as an Agent.

I am really struggling to get the UserMyFieldTelephone field to be populated.

Any suggestions as to where I am going wrong are very much appreciated.
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: Custom LDAP sync in Agent Preferences issue

Post by reneeb »

You need to change Kernel/System/User.pm to write the value to the preferences (see https://github.com/OTRS/otrs/blob/maste ... er.pm#L551)
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
duncan9562
Znuny newbie
Posts: 11
Joined: 23 Feb 2016, 14:51
Znuny Version: 5.0.14
Real Name: Duncan Mountford

Re: Custom LDAP sync in Agent Preferences issue

Post by duncan9562 »

Hi reneeb,

I tried adding the following, but this didn't seem to make much of a difference.

Code: Select all

    # set Telephone phone
    $Self->SetPreferences(
        UserID => $UserID,
        Key    => 'UserMyFieldTelephone',
        Value  => $Param{UserMyFieldTelephone},
    );
I assume logging out and logging back in to OTRS is enough to pull in the fields?

Thanks for your help.
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: Custom LDAP sync in Agent Preferences issue

Post by reneeb »

Yes, you're right...
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
duncan9562
Znuny newbie
Posts: 11
Joined: 23 Feb 2016, 14:51
Znuny Version: 5.0.14
Real Name: Duncan Mountford

Re: Custom LDAP sync in Agent Preferences issue

Post by duncan9562 »

Testing this, it seems to work for new users who haven't logged into OTRS, but doesn't update the field for existing users.

Have I missed something in User.pm for existing users....?
duncan9562
Znuny newbie
Posts: 11
Joined: 23 Feb 2016, 14:51
Znuny Version: 5.0.14
Real Name: Duncan Mountford

Re: Custom LDAP sync in Agent Preferences issue

Post by duncan9562 »

Ignore the last post, I found the Update and Add sections in User.pm and this now works perfectly.

Thanks for your help :)
gears
Znuny newbie
Posts: 38
Joined: 24 Feb 2011, 18:29
Znuny Version: 5.0.14

Re: Custom LDAP sync in Agent Preferences issue

Post by gears »

Excellent info in this thread. Along with https://blog.otrs.com/2011/09/05/agent- ... ignatures/ and verifying attributes sync mapping in /opt/otrs/Kernel/Config.pm it helped identify a problem syncing ad ldap telephonenumber attribute to agent preference fields & signature tags on 5.0.14.
OTRS 5.0.14 / Debian 7.11 x64 / Apache 2.2.22 / MySQL 14.14 Distrib 5.5.53
Post Reply