💾 Archived View for ldapguy.smol.pub › useful-wizardry-2022-02-11 captured on 2022-04-29 at 11:32:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
Playing with a long command with even longer parameters (LDAP line mode utility commands are commonly long). Typos are inevitable. The `base` DN was something like:
cn=Mantle,ou=outfield,ou=people,o=New York Yankees,dc=mlb,dc=com
It's a handful to type. But the directory's suffix, by guesswork is probably:
dc=mlb,dc=com
The suffix is useful so, working with this LDAP directory a lot I might define a shell variable:
mlb_suffix=dc=mlb,dc=com
And when I "echo" it:
echo $mlb_suffix dc=mlb,dc=com
Nice start. I would often use the names of players on the Yankees (I just made that up)
so I could set a shell variable:
nyy_players="o=New York Yankees,ou=players"
We need the quote because of the spaces in the value. Now we can echo:
echo $nyy_players,$mlb_suffix o=New York Yankees,ou=players,dc=mlb,dc=com
So our string is now:
cn=mantle,ou=outfield,$nyy_players,$mlb_suffix
The long, boring stuff is gone. It could be further reduced to
cn=mantle,$yankee_outfielders
And if I were obsessed with Yankee Outfielders, you can bet I'd get that defined.