Skip to main content
Question

LDAP pass variable without Uppercases


Forum|alt.badge.img+20
  • Valued Contributor
  • 732 replies

Hey everyone. I am running the current command at login to track LDAP and login:

sudo jamf recon -endUsername $3

How can I pass the username with all lowercases? I have tried:

#!/bin/sh
sudo jamf recon -endUsername $3 | tr '[A-Z]' '[a-z]'

This is an "at login" script.

5 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • May 21, 2013

First off, how are you seeing uppercase usernames coming from $3? Are they somehow set that way from your LDAP environment? Usually usernames are lowercase.

Anyway, what you have there won't work because you're trying to pipe the entire command into tr. I doubt the shell would understand what you're looking to do, which is to convert just $3 to lowercase.

Since it looks like you're running a script and not a Run Command one-liner, try this

#!/bin/sh

userAcct=$( echo $3 | tr '[A-Z]' '[a-z]' )
sudo jamf recon -endUsername $userAcct

Forum|alt.badge.img+20
  • Author
  • Valued Contributor
  • 732 replies
  • May 21, 2013

It has something to do with our LDAP. When the username comes up you get two options in an LDAP search.

UserName or username. UserName is default but I want username because that pulls all the LDAP info.


Forum|alt.badge.img+20
  • Author
  • Valued Contributor
  • 732 replies
  • May 21, 2013

Didn't work for me :(


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • May 21, 2013

Can you edit your LDAP mappings on your JSS to pull the correct information as its default? That would seem like a more sane approach than trying to work around the wrong information from the get-go.
If that's not possible or it will mess up a bunch of other things, can you provide an example or two of what you're seeing, maybe a username example?


Forum|alt.badge.img+7
  • Contributor
  • 56 replies
  • May 21, 2013

Try

sudo jamf recon -endUsername `echo $3 | tr '[A-Z]' '[a-z]'`

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings