I've got the following script output and it's OK, I'm trying to clean it up so that only the name of the group remains. Our computers can be in one or more groups in AD and I'm trying to get the Extended Attribute populated cleanly for use in creating smart groups. Current output looks like
dsAttrTypeNative:memberOf: CN=M_TEST,OU=Groups,OU=Location,DC=District,DC=loc CN=M_Shutdown_GPO_EXCLUSION,OU=Groups,OU=Location,DC=District,DC=loc
I know I can remove dsAttrTypeNative:memberOf: with one sed command and remove OU=Groups,OU=Location,DC=District,DC=loc with another, this will only work if I can guarentee that all groups will be in that same OU, which I can not.
Any help would be appreciated. Thank you
#!/bin/sh
ad_computer_name=`dsconfigad -show | grep "Computer Account" | awk '{print $4}'`
ad_computer_grp=`dscl /Search read /Computers/$ad_computer_name |
grep -A 1 dsAttrTypeNative:memberOf |
cut -d, -f1- `
echo "<result>$ad_computer_grp</result>"