How do I modify/delete a single attribute from the directory when I have multiple attributes of the same name. For example, given the following ldif: dn: cn=config,o=dhcp cn: config objectClass: top objectClass: dhcpService objectClass: dhcpOptions dhcpPrimaryDN: cn=server1,o=dhcp dhcpStatements: default-lease-time 600 dhcpStatements: max-lease-time 1200 dhcpStatements: ddns-update-style none dhcpStatements: boot-unknown-clients on dhcpStatements: log-facility local7
How would I modify just one of the dhcpStatements: attributes, for example, change 'dhcpStatements: log-facility local7' to 'dhcpStatements: log-facility local3'?
I've tried an ldif with: dn: cn=config,o=dhcp changetype: modify replace: dhcpStatements log-facility local7 dhcpStatements: log-facility local3 But that just gave me an error: ldapmodify: Undefined attribute type (17) additional info: dhcpStatements log-facility local7: AttributeDescription contains inappropriate characters.
I've also tried: dn: cn=config,o=dhcp changetype: modify replace: dhcpStatements dhcpStatements: log-facility local3 But that just gave me an error: replace modify: dhcpStatements replace dhcpStatements: log-facility local3 modifying entry "cn=config,o=dhcp" modify complete ldapmodify: Undefined attribute type (17) additional info: modify: attribute type undefined
I can use 'delete: dhcpStatements' but that deletes all of the dhcpStatements and then I have to add all of them back with the modification to the one that's needed.
So, what ldapmodify/ldif syntax is needed to specify which of multiple attributes should be modified? Thanks! Tom Leach
How do I modify/delete a single attribute from the directory when I have multiple attributes of the same name. For example, given the following ldif: dn: cn=config,o=dhcp cn: config objectClass: top objectClass: dhcpService objectClass: dhcpOptions dhcpPrimaryDN: cn=server1,o=dhcp dhcpStatements: default-lease-time 600 dhcpStatements: max-lease-time 1200 dhcpStatements: ddns-update-style none dhcpStatements: boot-unknown-clients on dhcpStatements: log-facility local7
How would I modify just one of the dhcpStatements: attributes, for example, change 'dhcpStatements: log-facility local7' to 'dhcpStatements: log-facility local3'?
I've tried an ldif with: dn: cn=config,o=dhcp changetype: modify replace: dhcpStatements log-facility local7 dhcpStatements: log-facility local3 But that just gave me an error: ldapmodify: Undefined attribute type (17) additional info: dhcpStatements log-facility local7: AttributeDescription contains inappropriate characters.
I've also tried: dn: cn=config,o=dhcp changetype: modify replace: dhcpStatements dhcpStatements: log-facility local3 But that just gave me an error: replace modify: dhcpStatements replace dhcpStatements: log-facility local3 modifying entry "cn=config,o=dhcp" modify complete ldapmodify: Undefined attribute type (17) additional info: modify: attribute type undefined
I can use 'delete: dhcpStatements' but that deletes all of the dhcpStatements and then I have to add all of them back with the modification to the one that's needed.
So, what ldapmodify/ldif syntax is needed to specify which of multiple attributes should be modified?
You need to use LDIF as specified in RFC 2849; note that there is a specific example that shows what you're trying to accomplish:
# Modify an entry: add an additional value to the postaladdress # attribute, completely delete the description attribute, replace # the telephonenumber attribute with two values, and delete a specific # value from the facsimiletelephonenumber attribute dn: cn=Paula Jensen, ou=Product Development, dc=airius, dc=com changetype: modify add: postaladdress postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086 - delete: description - replace: telephonenumber telephonenumber: +1 408 555 1234 telephonenumber: +1 408 555 5678 - delete: facsimiletelephonenumber facsimiletelephonenumber: +1 408 555 9876 -
In detail, look at the 'facsimiletelephonenumber' portion of the operation.
p.
On 7/3/10 1:24 AM, Tom Leach wrote:
So, what ldapmodify/ldif syntax is needed to specify which of multiple attributes should be modified? Thanks! Tom Leach
dn: cn=config,o=dhcp changetype: modify delete: dhcpStatements dhcpStatements: log-facility local7 - add: dhcpStatements dhcpStatements: log-facility local3 -
http://www.ietf.org/rfc/rfc2849.txt gives you the exact syntax and samples.
Thanks to everyone who replied. In my searching, I hadn't found any examples of modifying an attribute that had multiple values. the following ldif did exactly what I needed: dn: cn=config,o=dhcp changetype: modify delete: dhcpStatements dhcpStatements: log-facility local7 - add: dhcpStatements dhcpStatements: log-facility local3
I was stuck on trying to use 'replace' rather then 'delete + add' and I couldn't find an ldif syntax that worked.
Thanks again! Tom Leach
On 07/02/2010 04:24 PM, Tom Leach wrote:
How do I modify/delete a single attribute from the directory when I have multiple attributes of the same name. For example, given the following ldif: dn: cn=config,o=dhcp cn: config objectClass: top objectClass: dhcpService objectClass: dhcpOptions dhcpPrimaryDN: cn=server1,o=dhcp dhcpStatements: default-lease-time 600 dhcpStatements: max-lease-time 1200 dhcpStatements: ddns-update-style none dhcpStatements: boot-unknown-clients on dhcpStatements: log-facility local7
How would I modify just one of the dhcpStatements: attributes, for example, change 'dhcpStatements: log-facility local7' to 'dhcpStatements: log-facility local3'?
I've tried an ldif with: dn: cn=config,o=dhcp changetype: modify replace: dhcpStatements log-facility local7 dhcpStatements: log-facility local3 But that just gave me an error: ldapmodify: Undefined attribute type (17) additional info: dhcpStatements log-facility local7: AttributeDescription contains inappropriate characters.
I've also tried: dn: cn=config,o=dhcp changetype: modify replace: dhcpStatements dhcpStatements: log-facility local3 But that just gave me an error: replace modify: dhcpStatements replace dhcpStatements: log-facility local3 modifying entry "cn=config,o=dhcp" modify complete ldapmodify: Undefined attribute type (17) additional info: modify: attribute type undefined
I can use 'delete: dhcpStatements' but that deletes all of the dhcpStatements and then I have to add all of them back with the modification to the one that's needed.
So, what ldapmodify/ldif syntax is needed to specify which of multiple attributes should be modified? Thanks! Tom Leach
Tom Leach wrote:
Thanks to everyone who replied. In my searching, I hadn't found any examples of modifying an attribute that had multiple values.
See Example 6 in RFC 2849.
the following ldif did exactly what I needed: dn: cn=config,o=dhcp changetype: modify delete: dhcpStatements dhcpStatements: log-facility local7 - add: dhcpStatements dhcpStatements: log-facility local3
Note that this only works if the attribute type in question is declared with an EQUALITY matching rule (which is defined for dhcpStatements).
Ciao, Michael.
openldap-technical@openldap.org