Skip to content

Instantly share code, notes, and snippets.

@rhoerbe
Created June 2, 2017 18:08
Show Gist options
  • Save rhoerbe/3ecb0dae5aadd5bce1691f5e9b44fed9 to your computer and use it in GitHub Desktop.
Save rhoerbe/3ecb0dae5aadd5bce1691f5e9b44fed9 to your computer and use it in GitHub Desktop.
ldap tree diff (pseudo code)
# not correct:
read tree1 into list1
read tree2 into list2
for each entry1 in list1 {
compare entry1 with corresponding entry in list 2 // how to do this efficiently?
}
# better approach
compare ldap_trees() {
for item1 in tree1.search(all objects) {
item2 = tree2.search(dn=item1.dn) // exception on not found
compare_ldap_entries(item1, item2)
}
for item2 in tree2.search(all objects) {
item1 = tree1.search(dn=item2.dn) // exception on not found
compare_ldap_entries(item2, item21)
}
}
compare_ldap_entries(item1, item2) {
for each attribute1 in item1.attributes() {
compare_attribute_values(attribute1, item2[attribute1.name].values() // exception if different
for each attribute2 in item2.attributes() {
compare_attribute_values(attribute2, item1[attribute1.name].values() // exception if different
}
compare_attribute_values(attr1, attr2) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment