How to: With Kerberos detect users home drive and map it.

wlevan
New Contributor II

I think this is working without Binding to AD, but I bound to AD to get WiFi working with Certs and other requirements.

#!/bin/sh
localuser=$(ls -l /dev/console | cut -d " " -f4)
ADUser=$(app-sso -i yourdomain.com -j | grep user_name | sed 's/,//' | sed 's:\:/:g' | sed 's/user_name//g' | sed 's/"//g' | sed 's/://g' | tr -d ' ' | awk -F '@' '{print $1}')
homedir=$(app-sso -i yourdomain.com -j | grep home_directory | sed 's/,//' | sed 's:\:/:g' | sed 's/home_directory//g' | sed 's/"//g' | sed 's/://g' | tr -d ' ' | sed 's://:/:g')
echo "Mapping $homedir for $ADUser in $localuser profile"
export ADUser
export homedir
su $localuser -m -c 'mkdir ~/Desktop/$ADUser'
su $localuser -m -c 'mount_smbfs $homedir ~/Desktop/$ADUser'

Now I know I didn't do the sed's in the best way, so it might make some of you cringe. Replace yourdomain.com with your FQDN and it should work. If someone wants to add the detection of the FQDN that would be cool.

app-sso -l -j

Will give it to you, then you need to parse it. SED give me a headache but it is new to me.

0 REPLIES 0