Posted on 10-07-2014 12:27 PM
I have a script that worked perfectly the last 2 school years so probably pre-Casper 9. Since we upgraded to Casper 9 mid school year last year.
This script figures out who the current logged in user is and then hits Active Directory to get their AD group which is their graduation class and their full name. We then have departments named the same in Casper. This worked beautifully in the past but seems to have broken some time in the last year. And maybe it's my script but that hasn't changed.
#!/bin/bash
getUser=`ls -l /dev/console | awk '{ print $3 }'`
getclass=`dscl '/Active Directory/ACADEMIC/All Domains' -read /Users/$getUser dsAttrTypeNative:distinguishedName | awk '{ FS=","; print $2 }' | awk '{ FS="="; print $2 }'`
getRealName=`dscl '/Active Directory/ACADEMIC/All Domains' -read /Users/$getUser RealName | grep -v ":"`
jamf recon -endUsername $getUser -department "$getclass" -realname "$getRealName" -email "$getUser@saes.org"
When I do the jamf recon command but manually put -department "Class of 22" instead of using the variable it will set it to the department in Casper named "Class of 22" correctly.
When I check to make sure the variable $getclass has the right value it does (echo $getclass returns Class of 22).
Anyway I wasn't sure if this is a bug? Something I'm doing wrong? Something anyone else has seen? Any help would be greatly appreciated.
Solved! Go to Solution.
Posted on 10-08-2014 09:04 AM
You may want to double check that the string the variable is receiving is exactly what its required to be for the JSS to recognize the pre-defined department. What I mean is, if its being returned with even so much as an extra space or odd character in it, it may not match up and thus not populate when it gets recon'ed with that info.
You can have it echo the variable out to a text file as part of troubleshooting, and then check the text file afterwards to see what its echoing. It could even be a carriage return or something.
Posted on 10-07-2014 02:35 PM
Some predefined extension attributes are tied to JSS information and will only populate if it matches something in the list.
ie: Unless there is a department defined as "Class of 22" in the JSS it will not populate.
edit: That's my understanding anyway.
Posted on 10-07-2014 03:15 PM
No you are exactly right. And we have a department named "Class of 22" defined in Casper's list of available departments. It works in the script if I don't use the variable. That's why I'm so confused.
Posted on 10-07-2014 03:16 PM
@Look is correct. The department your wanting to match must already exist in the JSS.
Posted on 10-07-2014 04:41 PM
@boberito, have you got network segments overriding the departments?
Posted on 10-08-2014 05:56 AM
@bentoms Nope, not that I know of. We don't really use network segments at all here.
Posted on 10-08-2014 08:41 AM
When is this script being run? Is it possibly being run when a user isn't actually logged into the system?
Posted on 10-08-2014 08:43 AM
First login. All the other information populates perfectly like username, real name, and email.
Posted on 10-08-2014 09:04 AM
You may want to double check that the string the variable is receiving is exactly what its required to be for the JSS to recognize the pre-defined department. What I mean is, if its being returned with even so much as an extra space or odd character in it, it may not match up and thus not populate when it gets recon'ed with that info.
You can have it echo the variable out to a text file as part of troubleshooting, and then check the text file afterwards to see what its echoing. It could even be a carriage return or something.
Posted on 10-08-2014 10:37 AM
YES! You were right. I really really appreciate this. I guess I was lucky it was working before.