Create a new environment variable using LDAP parameters
Create a new environment variable using LDAP parameters
Hi,
I would like to get a LDAP parameter from the currently connected user and define it into an environment variable.
The idea would be to be able to call something from a template similar to [% Data.CurrentUserID %] but containing a specific LDAP attribute of the connected user, not just it's ID, and being able to call it from any page (an environment variable seems to be the solution for that, right ?)
I found out that it was possible to modify Layout.pm to create a new environment variable.
For example, it's possible to create a new variable called "New Variable" :
$Self->{NewVariable} = $ConfigObject->Get('DefaultTheme');
And call it inside a .tt template file using :
[% Env('NewVariable') %]
The LDAP attribute I'd like to use is defined in Config.pm as "UserEntity", which is an attribute we currently display on a ticket. What should I do to create a new variable containing it's value concerning the currently connected user ?
It seems it's not contained inside a ConfigObject but somewhere else...
Regards
Alexis
I would like to get a LDAP parameter from the currently connected user and define it into an environment variable.
The idea would be to be able to call something from a template similar to [% Data.CurrentUserID %] but containing a specific LDAP attribute of the connected user, not just it's ID, and being able to call it from any page (an environment variable seems to be the solution for that, right ?)
I found out that it was possible to modify Layout.pm to create a new environment variable.
For example, it's possible to create a new variable called "New Variable" :
$Self->{NewVariable} = $ConfigObject->Get('DefaultTheme');
And call it inside a .tt template file using :
[% Env('NewVariable') %]
The LDAP attribute I'd like to use is defined in Config.pm as "UserEntity", which is an attribute we currently display on a ticket. What should I do to create a new variable containing it's value concerning the currently connected user ?
It seems it's not contained inside a ConfigObject but somewhere else...
Regards
Alexis
-
- Administrator
- Posts: 3983
- Joined: 18 Dec 2007, 12:23
- Znuny Version: Znuny and Znuny LTS
- Real Name: Roy Kaldung
- Company: Znuny
- Contact:
Re: Create a new environment variable using LDAP parameters
Hi,
Usually, you should be able to access all attributes from the mapping in as long as the ticket data is pushed into the template. Did you checked this? In which module do you need this?
- Roy
Usually, you should be able to access all attributes from the mapping in as long as the ticket data is pushed into the template. Did you checked this? In which module do you need this?
- 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 ?
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 ?
Re: Create a new environment variable using LDAP parameters
Hi Roy,
I'm trying to access it from the different overviews in the Agent interface.
I'm not trying to get the ticket data, but the data from the currently connected Agent viewing the page. (who also exist as a user with all the LDAP attributes)
The mapping we use for this in Config.pm is like this :
[ 'UserEntity', 'Entity', 'aNameFromOurLDAP', 1, 0, 'var', 'https://ourwebsite.com/script?dept=[% Data.UserEntity | uri %]', 0 ],
I can't access is from the templates using [% UserEntity %] or [% Entity %] or [% Data.UserEntity %] or [% Data.Entity %]
This is why the only solution I have in mind is to add it to the Layout.pm to be able to access it in that way : [% Env(''UserEntity") %]
But maybe there would be another way ?
Alexis
I'm trying to access it from the different overviews in the Agent interface.
I'm not trying to get the ticket data, but the data from the currently connected Agent viewing the page. (who also exist as a user with all the LDAP attributes)
The mapping we use for this in Config.pm is like this :
[ 'UserEntity', 'Entity', 'aNameFromOurLDAP', 1, 0, 'var', 'https://ourwebsite.com/script?dept=[% Data.UserEntity | uri %]', 0 ],
I can't access is from the templates using [% UserEntity %] or [% Entity %] or [% Data.UserEntity %] or [% Data.Entity %]
This is why the only solution I have in mind is to add it to the Layout.pm to be able to access it in that way : [% Env(''UserEntity") %]
But maybe there would be another way ?
Alexis
Re: Create a new environment variable using LDAP parameters
Maybe adding a new field in the Agent informations and fill it with the mapping would make more sense ?
Then would it be accessible from any page ?
Then would it be accessible from any page ?
-
- Znuny superhero
- Posts: 629
- Joined: 24 Feb 2012, 03:58
- Znuny Version: LTS and Features
- Real Name: Mo Azfar
- Location: Kuala Lumpur, MY
- Contact:
Re: Create a new environment variable using LDAP parameters
You are looking for agent details while the AD mapping that you show is for the customer user..
Additionally, back in the day by default, we cant sync additional info from AD to agent profile..not sure on the latest version either can do this or not..
If can be sync, the variable may be access by [% Env("UserEntity") %], for example.
Additionally, back in the day by default, we cant sync additional info from AD to agent profile..not sure on the latest version either can do this or not..
If can be sync, the variable may be access by [% Env("UserEntity") %], for example.
My Github
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
Re: Create a new environment variable using LDAP parameters
Then I'm thinking about another solution :
All our agents also exists as customer users which contain the right attributes.
Would it be possible to perform a search on a User with the same ID than the Agent, get a specific attribute and store it into an environment variable in order to use that on any page ?
All our agents also exists as customer users which contain the right attributes.
Would it be possible to perform a search on a User with the same ID than the Agent, get a specific attribute and store it into an environment variable in order to use that on any page ?
-
- Znuny superhero
- Posts: 629
- Joined: 24 Feb 2012, 03:58
- Znuny Version: LTS and Features
- Real Name: Mo Azfar
- Location: Kuala Lumpur, MY
- Contact:
Re: Create a new environment variable using LDAP parameters
Just tested..
look like additional LDAP attributes can be pull from LDAP to Agent profile..
for example phone number..
then you can access it by [% Env("UserPhoneNumber") | html %] in template file..
and, of course you have to create the agent preferences field first to store this value.
viewtopic.php?t=19936
look like additional LDAP attributes can be pull from LDAP to Agent profile..
for example phone number..
Code: Select all
$Self->{'AuthSyncModule::LDAP::UserSyncMap2'} = {
# DB -> LDAP
UserFirstname => 'givenName',
UserLastname => 'sn',
UserEmail => 'mail',
UserPhoneNumber => 'telephonenumber',
};
and, of course you have to create the agent preferences field first to store this value.
viewtopic.php?t=19936
You do not have the required permissions to view the files attached to this post.
My Github
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
-
- Administrator
- Posts: 3983
- Joined: 18 Dec 2007, 12:23
- Znuny Version: Znuny and Znuny LTS
- Real Name: Roy Kaldung
- Company: Znuny
- Contact:
Re: Create a new environment variable using LDAP parameters
Hi,
JFI, this feature is available since vrsion 6.
- 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 ?
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 ?
Re: Create a new environment variable using LDAP parameters
Did you write a new Module in Custom/Kernel/ adding a modification of System/Auth/Sync/LDAP.pm ?skullz wrote: ↑21 Aug 2020, 16:22Code: Select all
$Self->{'AuthSyncModule::LDAP::UserSyncMap2'} = { # DB -> LDAP UserFirstname => 'givenName', UserLastname => 'sn', UserEmail => 'mail', UserPhoneNumber => 'telephonenumber', };
What did you change from the original AuthSyncModule::LDAP::UserSyncMap ?
Regards
Alexis
-
- Znuny superhero
- Posts: 629
- Joined: 24 Feb 2012, 03:58
- Znuny Version: LTS and Features
- Real Name: Mo Azfar
- Location: Kuala Lumpur, MY
- Contact:
Re: Create a new environment variable using LDAP parameters
No need to change anything at core code level..ahauser wrote: ↑28 Aug 2020, 11:53Did you write a new Module in Custom/Kernel/ adding a modification of System/Auth/Sync/LDAP.pm ?skullz wrote: ↑21 Aug 2020, 16:22Code: Select all
$Self->{'AuthSyncModule::LDAP::UserSyncMap2'} = { # DB -> LDAP UserFirstname => 'givenName', UserLastname => 'sn', UserEmail => 'mail', UserPhoneNumber => 'telephonenumber', };
What did you change from the original AuthSyncModule::LDAP::UserSyncMap ?
Regards
Alexisdetai
Normally, AD connection details are define in Config.pm.
So in Config.pm, within $Self->{'AuthSyncModule::LDAP::UserSyncMap'} block, add
Code: Select all
UserPhoneNumber => 'telephonenumber',
My Github
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
Re: Create a new environment variable using LDAP parameters
Actually it seems I was missing the part with :
I don't get it : it works with your example, I can display the phone number on the page using UserPhoneNumber, but if I try wih something else it doesn't...
Example, I created a new agent preference field. I can see it appears correctly in the Sysconfig :
I added it in the mapping in Config.pm, with a simple attribute first : mail :
Then I added it in the AgentTicketZoom.tt :
But nothing... Only the phone number of your example displays... Maybe I missed something ?
Code: Select all
$Self->{'AuthSyncModule'} = 'Kernel::System::Auth::Sync::LDAP';
$Self->{'AuthSyncModule::LDAP::XXX'} =
Example, I created a new agent preference field. I can see it appears correctly in the Sysconfig :
Code: Select all
<Setting Name="PreferencesGroups###AgentEntity" Required="0" Valid="1">
<Description Translatable="1">A longer discription that describes what this field does</Description>
<Navigation>Frontend::Agent::View::Preferences</Navigation>
<Value>
<Hash>
<Item Key="Module">Kernel::Output::HTML::Preferences::Generic</Item>
<Item Key="PreferenceGroup">Miscellaneous</Item>
<Item Key="Label" Translatable="1">AgentEntity</Item>
<Item Key="Desc" Translatable="1">Something that describes what this field is about.</Item>
<Item Key="Key" Translatable="1"></Item>
<Item Key="Prio">2345</Item>
<Item Key="Active">1</Item>
</Hash>
</Value>
</Setting>
Code: Select all
$Self->{'AuthSyncModule::LDAP::UserSyncMap'} = {
## # DB -> LDAP
UserPhoneNumber => 'telephoneNumber',
AgentEntity => 'mail',
};
Code: Select all
[% Env("UserPhoneNumber") | html %]
[% Env("AgentEntity") | html %]
-
- Znuny superhero
- Posts: 629
- Joined: 24 Feb 2012, 03:58
- Znuny Version: LTS and Features
- Real Name: Mo Azfar
- Location: Kuala Lumpur, MY
- Contact:
Re: Create a new environment variable using LDAP parameters
1. Just tested it..look like must used the prefix 'User'
So instead of
Use
2. XML should look like this
So instead of
Code: Select all
AgentEntity => 'mail',
Code: Select all
UserEntity => 'mail',
2. XML should look like this
Code: Select all
<Setting Name="PreferencesGroups###Entity" Required="0" Valid="1">
<Description Translatable="1">Defines the config parameters of this item, to be shown in the preferences view. Please note: setting 'Active' to 0 will only prevent agents from editing settings of this group in their personal preferences, but will still allow administrators to edit the settings of another user's behalf. Use 'PreferenceGroup' to control in which area these settings should be shown in the user interface.</Description>
<Navigation>Frontend::Agent::View::Preferences</Navigation>
<Value>
<Hash>
<Item Key="Module">Kernel::Output::HTML::Preferences::Generic</Item>
<Item Key="PreferenceGroup">Miscellaneous</Item>
<Item Key="Label" Translatable="1">Entity</Item>
<Item Key="Desc" Translatable="1">This is a Description for Entity</Item>
<Item Key="Key" Translatable="1">Entity</Item>
<Item Key="Block">Input</Item>
<Item Key="Data">[% Env("UserEntity") %]</Item>
<Item Key="PrefKey">UserEntity</Item>
<Item Key="Prio">7000</Item>
<Item Key="Active">1</Item>
</Hash>
</Value>
</Setting>
My Github
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
OTRS CE/LTS Discord Channel
Cant Update Package Anymore ? Check This
Professional OTRS, Znuny & OTOBO services: efflux.de/en
Free and premium add-ons: English
Re: Create a new environment variable using LDAP parameters
Thanks a lot, it works !
However, on one of the development server we're using, the password is removed everytime after login.
I don't see any other differences except this server doesn't have a SSO login configured.
Could it be related ?
Any ideas ?
However, on one of the development server we're using, the password is removed everytime after login.
I don't see any other differences except this server doesn't have a SSO login configured.
Could it be related ?
Any ideas ?
-
- Znuny newbie
- Posts: 22
- Joined: 19 Jul 2019, 16:31
- Znuny Version: 6.0.14
- Real Name: Gerald
- Company: INRA
Re: Create a new environment variable using LDAP parameters
Hi,
do you know how we can use this field in the signature?
I tried adding
$Env{"UserEntity"}
in the signature, but it is not interpreted...
thank you for your help
Gérald
do you know how we can use this field in the signature?
I tried adding
$Env{"UserEntity"}
in the signature, but it is not interpreted...
thank you for your help
Gérald
OTRS : 6.0.29, with FAQ extension, on centOS7
Agent auth against local database (postgresql 9)
Agent auth against local database (postgresql 9)
Re: Create a new environment variable using LDAP parameters
For me this works :
<OTRS_CURRENT_UserCity>
<OTRS_CURRENT_UserCity>
-
- Administrator
- Posts: 3983
- Joined: 18 Dec 2007, 12:23
- Znuny Version: Znuny and Znuny LTS
- Real Name: Roy Kaldung
- Company: Znuny
- Contact:
Re: Create a new environment variable using LDAP parameters
Hi,
It should be <OTRS_OWNER_UserEntity> / <OTRS_CURRENT_UserEntity> / <OTRS_RESPONSIBLE_UserEntity>
- Roy
It should be <OTRS_OWNER_UserEntity> / <OTRS_CURRENT_UserEntity> / <OTRS_RESPONSIBLE_UserEntity>
- 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 ?
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 ?
-
- Znuny newbie
- Posts: 22
- Joined: 19 Jul 2019, 16:31
- Znuny Version: 6.0.14
- Real Name: Gerald
- Company: INRA
Re: Create a new environment variable using LDAP parameters
wonderful!!
thank you very much
thank you very much
OTRS : 6.0.29, with FAQ extension, on centOS7
Agent auth against local database (postgresql 9)
Agent auth against local database (postgresql 9)
[Solved] Re: Create a new environment variable using LDAP parameters
As my initial question is solved, I will create new posts for other related questions.