I implement a UI for better Overview about our LDAP branchs. For that I want to use Angular Materials Tree. It´s great and very intuitiv to click through all branches. (https://material.angular.io/components/tree/overview)
What I have:
Array of multiple LDAP paths as a String:
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'
]
What I already did:
I convertet this Strings to Array of standalone paths with dependencies. example 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}
]
What I need:
I need an Object in which all keys are paths of our LDAP:
{
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 already tried to use methods like that: Build tree array from flat array in javascript But this algorithmus use push function to add the new branches to an arraykey. I need that the key is an object with more keys.