I'm working on implementing a user interface to offer a comprehensive overview of our LDAP branches. To achieve this, I plan to utilize Angular Materials Tree as it provides a smooth and intuitive browsing experience through all the branches (https://material.angular.io/components/tree/overview)
My Current Setup:
I have an array containing multiple LDAP paths represented as strings:
groups = [
'cn=devops,ou=smallUnit1,ou=unit1,o=group1,c=de',
'cn=devops,ou=smallUnit1,ou=unit1,o=group2,c=de',
'cn=devops,ou=smallUnit2,ou=unit1,o=group1,c=de',
'cn=dev,ou=smallUnit1,ou=unit2,o=group1,c=de',
'cn=dev,ou=smallUnit1,ou=unit1,o=group2,c=de',
'cn=ops,ou=smallUnit1,ou=unit1,o=group1,c=de'
]
Progress So Far:
I've transformed these strings into arrays of standalone paths with dependencies. For example, here's the breakdown for groups[0]:
dependencies = [
{id: 'c=de', parent: NULL, child: 'o=group1'},
{id: 'o=group1', parent: 'c=de', child: 'ou=unit1'},
{id: 'ou=unit1', parent: 'o=group1', child: 'ou=smallUnit1'},
{id: 'ou=smallUnit1', parent: 'ou=unit1', child: 'cn=devops'},
{id: 'cn=devops', parent: 'ou=smallUnit1', child: NULL}
]
Next Steps:
I require an object where keys represent paths in our LDAP structure:
{
c=de: {
o=group1: {
ou=unit1: {
ou=smallUnit1: {
cn=devops: {},
cn=ops: {}
},
ou=smallUnit2: {
cn=devops: {}
}
},
ou=unit2: {
ou=smallUnit1: {
cn=dev: {}
}
}
},
o=group2: {
ou=unit1: {
ou=smallUnit1: {
cn=devops: {},
cn=dev: {}
}
}
}
}
}
I've attempted to implement methods similar to those discussed here: Build tree array from flat array in javascript However, the algorithm uses push functions to add new branches which doesn't align with my requirement of having keys as nested objects.