💾 Archived View for ldapguy.smol.pub › useful-wizardry-2022-02-11 captured on 2023-11-04 at 11:36:58. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

➡️ Next capture (2024-08-18)

-=-=-=-=-=-=-

Useful Wizardy

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.