Posted on 04-14-2014 09:46 AM
I'm curious if there is a way that I can use an extension attribute to list the name of the computer object being used for the bind to Active Directory. All I can see in my JSS currently is a bind status of "Not Bound" or the name of the domain it is bound to. Since the name of the computer (hostname for example) does not always match the computer object name, I'd like to have that listed under the Operating System tab. I would imagine this is achievable via an extension attribute script, but I'm not positive which command would be easiest and most reliable to use.
Solved! Go to Solution.
Posted on 04-14-2014 10:19 AM
#!/bin/sh
ADCompName=$( dsconfigad -show | awk '/Computer Account/{print $NF}' | sed 's/$$//' )
echo "<result>$ADCompName</result>"
Posted on 04-14-2014 10:22 AM
I think something like this would work, you may need to test it out though: ```
adComputerName=dsconfigad -show | grep "Computer Account" | cut -d "=" -f2
trimmedComputerName=${adComputerName%?}
echo "<result>$trimmedComputerName</result>"
```
Posted on 04-14-2014 11:57 AM
Here is what I use, I make the name uppercase for readability and consistency with other processes:
#!/bin/bash
adName=`dsconfigad -show | grep "Computer Account" | awk '{print toupper}' | awk '{print $4}' | sed 's/$$//'`
if [ ! "$adName" ]; then
adName="Not Bound"
fi
echo "<result>$adName</result>"
Posted on 04-14-2014 09:49 AM
I'm not 100% sure if this is correct but this is what I used once upon a time for a similar situation:
#!/bin/sh
adComputerName=`dsconfigad -show | grep "Computer Account" | cut -d "=" -f2`
echo "<result>$adComputerName</result>"
Posted on 04-14-2014 09:58 AM
@smb_samba, that script works wonderfully. The only problem I have with it is that it appends a "$" to the end of the name. Is that avoidable? If not, I'm totally happy with this. Thank you!
Posted on 04-14-2014 10:19 AM
#!/bin/sh
ADCompName=$( dsconfigad -show | awk '/Computer Account/{print $NF}' | sed 's/$$//' )
echo "<result>$ADCompName</result>"
Posted on 04-14-2014 10:22 AM
I think something like this would work, you may need to test it out though: ```
adComputerName=dsconfigad -show | grep "Computer Account" | cut -d "=" -f2
trimmedComputerName=${adComputerName%?}
echo "<result>$trimmedComputerName</result>"
```
Posted on 04-14-2014 11:57 AM
Here is what I use, I make the name uppercase for readability and consistency with other processes:
#!/bin/bash
adName=`dsconfigad -show | grep "Computer Account" | awk '{print toupper}' | awk '{print $4}' | sed 's/$$//'`
if [ ! "$adName" ]; then
adName="Not Bound"
fi
echo "<result>$adName</result>"
Posted on 04-15-2014 01:15 PM
@smb_samba, @mm2270, and @alexjdale:
Those work great. The added benefit of having it printed to uppercase is a great extra. Thank you all for your responses!