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
Obtaining Manager LDAP Data in "Non-DN" format
Moderator: crythias
Obtaining Manager LDAP Data in "Non-DN" format
Setup:
OTRS 6.0.12
Hosted on CentOS 7.4/ MySQL - MariaDB (5.5.60)
OTRS 6.0.12
Hosted on CentOS 7.4/ MySQL - MariaDB (5.5.60)
-
- 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
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
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
Re: Obtaining Manager LDAP Data in "Non-DN" format
Hi,
You can use the same trick as well as with picture.
Config.pm
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 ],
],
};
-
- 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
This is exactly what I need. I would then to adapt the JS line for my needs and I'm really not confident.
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.
and then I would like to remove text from the first comma.
Thank you for your help
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 ],
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 ],
Thank you for your help
Centos 7 / OTRS::ITSM 6 Business Solutions / MariaDB / Apache
Re: Obtaining Manager LDAP Data in "Non-DN" format
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
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
Re: Obtaining Manager LDAP Data in "Non-DN" format
Hi again,
I've found a working solution.
I would like to share it with you here.
Cheers,
lymac
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 ],
lymac