Changes

Jump to: navigation, search

stoney core: OpenLDAP ldapseach and replace

637 bytes added, 12:18, 14 December 2020
/* Search an replace - Replace a section (part) of an attribute - Step by step */
-D "$ldap_bind_account" \
-w "$ldap_bind_password" \
"(${ldap_attribute}=*${ldap_attribute_old}*)"
</source>
The result will contain something like:
<source lang='ldif'>
dn: ousstVirtualMachine=unsuccessful1a08a4b8-8daf-43d7-b7c0-6e92cf7c1db1,ou=templates,uid=5000000virtual machines ,ou=reseller,ou=configuration,ou=b ackupvirtualization,ou=services,o=stepping-stone,c=chdescriptionobjectClass: This leaf contains the quota templates for the (online) backupsersstVirtualizationVirtualMachine vice.objectClass: sstRelationshipobjectClass: sstSpiceobjectClass: labeledURIObject
objectClass: top
objectClasssstClockOffset: organizationalUnitutcobjectClasssstDisplayName: sstTemplateSetupoukvm-1243: unsuccessfulsstMailFrom: Support stepping stone GmbH <support@: CentOS 7 (Zabbix Database)sstMemory: 17179869184sstNode: vm-node-03.stepping-stone.ch>sstMailTemplatesstOnCrash: filedestroysstOnPowerOff:///var/www/selfcare/htdocs/themes/selfcaredestroysstOnReboot: restartsstOSArchitecture: x86_64sstOSBootDevice: hdsstOSMachine: pc-inti440fx-2.stepping1sstOSType: hvmsstStatus: runningsstType: kvmsstVCPU: 10sstVirtualMachine: 1a08a4b8-8daf-43d7-b7c0-6e92cf7c1db1 sstVirtualMachinePool: d9c3cc0c-9ae7-40e5-8fb7-ba5297e835aadescription: kvm-1243: stepping stone.ch/templates/services/backup/unsuccessful/unsuccessful_mailGmbH: CentOS 7 (Zabbix Database)sstMailTemplateFormatSourcesstFeature: txtacpisstMailTemplateFormatTargetsstFeature: txtpaesstMailTemplateResellersstVirtualMachineMode: fileready for usesstVirtualMachineType:///var/www/selfcare/htdocs/themes/selfcare-int.spersistent teppingsstVirtualMachineSubType: ServersstNetworkDomainName: stepping-stone.chsstNetworkHostname: kvm-1243uid: 3733401sstBelongsToCustomerUID: 3723426sstBelongsToPersonUID: 1000000sstBelongsToResellerUID: 2000000sstSpicePort: 5906sstSpicePassword: HCfNmk6sY9PWlabeledURI: ldap:/templates/services/backup/unsuccessful/unsuccessful_mail_ressstVirtualMachine=default,ou=default,ou=default,ou=default eller,ou=linux,ou=virtual machine profiles,ou=virtualization,ou=services,o=steppinsstMailTemplateResellerFormatSource: txt g-stone,c=chsstMailTemplateResellerFormatTargetmember: txtsstVirtualMachine=default,ou=default,ou=default,ou=default,ou=linux,ou =virtual machine profiles,ou=virtualization,ou=services,o=stepping-stone,c=ch
</source>
As we are only interested in Normalize the dn, we add output (without the following two lines to the search aboveldif 80 characters per line restriction):
<source lang='bash'>
| awk '{ if (/^ /) { sub(/^ /, ""); } else printf "\n"; printf "%s", $0 }' \
| awk '/^dn: / { print $2 }'
</source>
3,368
edits