Skip to main content
Solved

Ext Attribute - List AD Computer Object Name


Forum|alt.badge.img+16

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.

Best answer by mm2270

#!/bin/sh

ADCompName=$( dsconfigad -show | awk '/Computer Account/{print $NF}' | sed 's/$$//' )

echo "<result>$ADCompName</result>"
View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+4
  • Contributor
  • 10 replies
  • April 14, 2014

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>"

Forum|alt.badge.img+16
  • Author
  • Employee
  • 210 replies
  • April 14, 2014

@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!


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • Answer
  • April 14, 2014
#!/bin/sh

ADCompName=$( dsconfigad -show | awk '/Computer Account/{print $NF}' | sed 's/$$//' )

echo "<result>$ADCompName</result>"

Forum|alt.badge.img+4
  • Contributor
  • 10 replies
  • April 14, 2014

I think something like this would work, you may need to test it out though: ```

!/bin/sh

adComputerName=dsconfigad -show | grep "Computer Account" | cut -d "=" -f2
trimmedComputerName=${adComputerName%?}
echo "<result>$trimmedComputerName</result>"
```


Forum|alt.badge.img+17
  • Contributor
  • 881 replies
  • April 14, 2014

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>"

Forum|alt.badge.img+16
  • Author
  • Employee
  • 210 replies
  • April 15, 2014

@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!


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