CLI script for modifying values in a multi-value LDAP attribute
Budget: $30 – $250 USD
I need a command line tool for Linux that searches an LDAP directory with a specific filter and, for each entry found, modifies two values that are part of a multi-value attribute.
My LDAP directory entries have an attribute, radiusReplyItem, with multiple values. I need to modify all entries matching the filter and replace some of these values having a specific pattern with different ones, the other values must not be changed.
I'm expecting a script that, provided two search values, search_value1 and search_value2, connects to an LDAP server and modifies the matching entries in the LDAP directory with replace_value1 and replace_value2, respectively.
For example, I want the script to replace the values for all entries matching the filter '(&(radiusReplyItem=X-OldPlan-Out+="old-25")(radiusReplyItem=X-OldPlan-In+="old-30"))' with two new values
If I configure the script with these values:
search_value1='X-OldPlan-Out+="old-25"'
search_value2='X-OldPlan-In+="old-30"'
replace_value1='X-NewPlan-Out+="new-25"'
replace_value2='X-NewPlan-In+="new-30"'
The script should modify this dn entry:
before the ldap modification:
"""
dn: uid=john,ou=People,dc=local
objectClass: top
objectClass: inetOrgPerson
objectClass: radiusprofile
[...]
radiusReplyItem: X-Domain="x.y.z"
radiusReplyItem: X-OldPlan-Out+="old-25"
radiusReplyItem: X-Room="991"
radiusReplyItem: X-OldPlan-In+="old-30"
"""
after the ldap modification:
"""
dn: uid=john,ou=People,dc=local
objectClass: top
objectClass: inetOrgPerson
objectClass: radiusprofile
[...]
radiusReplyItem: X-Domain="x.y.z"
radiusReplyItem: X-NewPlan-Out+="new-25"
radiusReplyItem: X-Room="991"
radiusReplyItem: X-NewPlan-In+="new-30"
"""
The script must run on any recent Linux distribution. You can use bash, python, golang or whatever you prefer.
My LDAP directory entries have an attribute, radiusReplyItem, with multiple values. I need to modify all entries matching the filter and replace some of these values having a specific pattern with different ones, the other values must not be changed.
I'm expecting a script that, provided two search values, search_value1 and search_value2, connects to an LDAP server and modifies the matching entries in the LDAP directory with replace_value1 and replace_value2, respectively.
For example, I want the script to replace the values for all entries matching the filter '(&(radiusReplyItem=X-OldPlan-Out+="old-25")(radiusReplyItem=X-OldPlan-In+="old-30"))' with two new values
If I configure the script with these values:
search_value1='X-OldPlan-Out+="old-25"'
search_value2='X-OldPlan-In+="old-30"'
replace_value1='X-NewPlan-Out+="new-25"'
replace_value2='X-NewPlan-In+="new-30"'
The script should modify this dn entry:
before the ldap modification:
"""
dn: uid=john,ou=People,dc=local
objectClass: top
objectClass: inetOrgPerson
objectClass: radiusprofile
[...]
radiusReplyItem: X-Domain="x.y.z"
radiusReplyItem: X-OldPlan-Out+="old-25"
radiusReplyItem: X-Room="991"
radiusReplyItem: X-OldPlan-In+="old-30"
"""
after the ldap modification:
"""
dn: uid=john,ou=People,dc=local
objectClass: top
objectClass: inetOrgPerson
objectClass: radiusprofile
[...]
radiusReplyItem: X-Domain="x.y.z"
radiusReplyItem: X-NewPlan-Out+="new-25"
radiusReplyItem: X-Room="991"
radiusReplyItem: X-NewPlan-In+="new-30"
"""
The script must run on any recent Linux distribution. You can use bash, python, golang or whatever you prefer.