Dear List:
I use openldap 2.2.13 on RHEL and having 4000+ entries.
I have the following requirement.
1. Add one attribute for all the records. 2. Set a value to it, which is already set for another attribute of the same record.
A SQL command of the following type would have done this job, if my data was in SQL.
update data set newattr=oldattr;
Is there any equivalent Openldap command, which can be used to do this.
Regards,
Anant Athavale.
with a simple bash script you can do that
step 1) search ldap directory and extract the pair (dn,oldattr) (where dn is something like that "dn: uid=user,ou=people,dc(o)=domain,dc(c)=net" and oldattr is something like that "attribute: value"
step 2) foreach pair you run and ldapmodify -f file .... where file is something like that
dn: uid=user,ou=people,dc(o)=domain,dc(c)=net changetype: modify replace: oldattr - add: newattr newattr: value -
man ldapsearch + man ldapmodify
On 12/4/06, Anant S Athavale asa@isac.gov.in wrote:
Dear List:
I use openldap 2.2.13 on RHEL and having 4000+ entries.
I have the following requirement.
- Add one attribute for all the records.
- Set a value to it, which is already set for another attribute of
the same record.
A SQL command of the following type would have done this job, if my data was in SQL.
update data set newattr=oldattr;
Is there any equivalent Openldap command, which can be used to do this.
Regards,
Anant Athavale.
Anant S Athavale wrote:
I use openldap 2.2.13 on RHEL and having 4000+ entries.
Update to Buchan Milne's 2.3.whatever (ours on RHAS4 is 2.3.30 using his older rpm specfile).
I have the following requirement.
- Add one attribute for all the records.
Ok, but only if that attribute is included in one of the objectClasses allowed by the respective schema that you've loaded.
- Set a value to it, which is already set for another attribute of the
same record.
See the above.
A SQL command of the following type would have done this job, if my data was in SQL.
update data set newattr=oldattr;
Is there any equivalent Openldap command, which can be used to do this.
We do that kind of thing (and often) with a small (20 lines?) shell script using ldapsearch incorporating ldapmodify and a here document.
Now this was probably not the answer that you were hoping for, since the mindsets involved in SQL and LDAP are quite different. Nevertheless, it's the kind of script that, once you've got into the swing of things, will take you a couple of minutes to adapt. Though "getting into the swing of things" could cost you some time, just like learning SQL.
Best,
--Tonni
openldap-software@openldap.org