Obtaining Manager LDAP Data in "Non-DN" format

Moderator: crythias

Post Reply
retro2707
Znuny advanced
Posts: 131
Joined: 16 Apr 2014, 17:06
Znuny Version: 6.0.12

Obtaining Manager LDAP Data in "Non-DN" format

Post by retro2707 »

Hi and thanks for reading,

I have successfully mapped a variable and stored that in OTRS for the manager LDAP attribute.

Howerver, it is a DN in the format:

CN=Mike Stokes,OU=Users,OU=Senior Management,DC=domain,DC=local

I just want the Dynamic Field to store "Mike Stokes". Is this possible using some sort of regex or via some other method?

Cheers,

Brendan
Setup:
OTRS 6.0.12
Hosted on CentOS 7.4/ MySQL - MariaDB (5.5.60)
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Obtaining Manager LDAP Data in "Non-DN" format

Post by crythias »

The problem is that the value comes as-is from the field.
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
drgrabol
Znuny newbie
Posts: 1
Joined: 30 Jun 2014, 09:38
Znuny Version: 3.3.5

Re: Obtaining Manager LDAP Data in "Non-DN" format

Post by drgrabol »

Hi,
You can use the same trick as well as with picture.
Config.pm

Code: Select all

    Map => [
        # note: Login, Email and CustomerID are mandatory!
        # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
	[ 'UserPicture', '', 'sAMAccountName', 1, 0, 'var', '#"></a><img  height="96" src="https://otrs.xxx.xxl/photo.php?username=$Data{"UserPicture"}" /><br/><a style="display: none;" href="#', 0 ],
        [ 'UserTitle',      'Title',      'title',           1, 0, 'var', '', 0 ],
        [ 'UserFirstname',  'Firstname',  'givenname',       1, 1, 'var', '', 0 ],
        [ 'UserLastname',   'Lastname',   'sn',              1, 1, 'var', '', 0 ],
        [ 'UserLogin',      'Username',   'sAMAccountName',  1, 1, 'var', '', 0 ],
        [ 'UserEmail',      'Email',      'mail',            1, 0, 'var', '', 0 ],
        [ 'UserCustomerID', 'CustomerID', 'mail',            0, 1, 'var', '', 0 ],
#        [ 'UserCustomerIDs', 'CustomerIDs', 'second_customer_ids', 1, 0, 'var', '', 0 ],
        [ 'UserCompany', 'Firma', 'company', 1, 0, 'var', '', 0 ],
        [ 'UserDepartment', 'Departament', 'department', 1, 0, 'var', '', 0 ],
        [ 'UserPhone',      'Phone',      'telephonenumber', 1, 0, 'var', '', 0 ],
        [ 'UserMobile',     'Mobile',     'mobile',       1, 0, 'var', '', 0 ],
        [ 'UserAddress',    'Lokalizacja',    'physicalDeliveryOfficeName',   1, 0, 'var', '', 0 ],
#        [ 'UserManager',    'Manager',   'manager',   1, 0, 'var', '', 1 ],
	[ 'UserManager', 'Manager', 'manager', 1, 0, 'var', '#"></a><script type="text/javascript">var body ="$Data{"UserManager"}",result=body.replace(/(cn=)/ig, ""),result=result.replace(/,ou=XXXX,dc=XXXX,dc=XXX,dc=XXX/ig, ""),result=result.replace(/ou=/ig, " ");document.write(result);</script><a style="display: none;" href="#', 0 ],
		#        [ 'UserComment',    'Comment',    'description',     1, 0, 'var', '', 0 ],
    ],
};
Sayannara
Znuny advanced
Posts: 118
Joined: 22 May 2012, 12:37
Znuny Version: OTRS 7.06
Real Name: Yann
Company: FVE
Contact:

Re: Obtaining Manager LDAP Data in "Non-DN" format

Post by Sayannara »

This is exactly what I need. I would then to adapt the JS line for my needs and I'm really not confident.

Code: Select all

</a><script type="text/javascript">
	var body ="$Data{"UserManager"}",
	result=body.replace(/(cn=)/ig, ""),
	result=result.replace(/,ou=XXXX,dc=XXXX,dc=XXX,dc=XXX/ig, ""),
	result=result.replace(/ou=/ig, " ");
	document.write(result);
</script><a style="display: none;" href="#', 0 ],
First of all, I would be able to remove the "CN=" but nothing is displayed. I don't know why there is "style="display: none;", so I tried to remove it.

Code: Select all

</a><script type="text/javascript">
	var body ="$Data{"UserManager"}",
	result=body.replace(/(cn=)/ig, "");
	document.write(result);
</script><a style="display: none;" href="#', 0 ],
and then I would like to remove text from the first comma.
Thank you for your help
Centos 7 / OTRS::ITSM 6 Business Solutions / MariaDB / Apache
lymac
Znuny newbie
Posts: 8
Joined: 20 May 2015, 09:53
Znuny Version: 4.0.8

Re: Obtaining Manager LDAP Data in "Non-DN" format

Post by lymac »

Hello

Has anyone successfully used this workaround or code snippet?
I tried to integrate it into config.pm, but the field always remains empty.
Only a small area above reacts to a mousehover.

Cheers,
lymac
lymac
Znuny newbie
Posts: 8
Joined: 20 May 2015, 09:53
Znuny Version: 4.0.8

Re: Obtaining Manager LDAP Data in "Non-DN" format

Post by lymac »

Hi again,

I've found a working solution.
I would like to share it with you here.

Code: Select all

[ 'UserManager',     'Manager',     'manager',     1,     0,     'var',     '#" id="adManager" ><script type="text/javascript">var body="[% Data.UserManager | html %]"; var result = /^CN=(.+?),/.exec(body)[1];$("#adManager").text(result);</script>',	0	],
Cheers,
lymac
Post Reply