I need to make an extension attribute to check for a certain group on our AD. I can list all groups based on user but no luck basing it off computer name. Any ideas?
List All Active Directory Groups that a computer belongs to.
Best answer by BradLines
I got it working! its kinda rudimentary but it does the trick and easy to read for a non-bash scripter
#!/bin/bash
domainName=`echo show com.apple.opendirectoryd.ActiveDirectory |scutil | grep DomainNameFlat | awk '{print $3}'`
if [ $? -ne 0 ]
then
echo "Failed to get domain name, exiting script"
exit 1
fi
if [ -z $domainName ]
then
echo "Failed to get domain name, exiting script"
exit 1
fi
computerName=$(networksetup -getcomputername)
upn=`dscl "/Active Directory/$domainName/All Domains" read "/Groups/NameOfTheGroup" GroupMembership`
inGroup="no"
for u in $upn; do
if [[ "$u" == "$computerName" ]] ; then
inGroup="yes"
break
fi
done
echo "<result>$inGroup</result>"
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
