Advertisement
jaimerosariojusticia

Gets wbinfo table of Users with username & primary group

Jul 7th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. for ADUSER in $(wbinfo -u --domain="$(wbinfo --own-domain)" | sort)
  2. do WBSEP=$(wbinfo --separator)
  3. ADUNAME=$(wbinfo -i "$ADUSER" | cut -d ":" -f5)
  4. UINFO=$(wbinfo -i "$ADUSER" | cut -d ":" -f3)
  5. GINFO=$(wbinfo -i "$ADUSER" | cut -d ":" -f4)
  6. SIDU=$(wbinfo -U "$UINFO")
  7. SIDG=$(wbinfo -G "$GINFO")
  8. USERID=$(wbinfo -s "$SIDU" | sed 's/.\{1\}$//' | cut -d "$WBSEP" -f2)
  9. GROUPID=$(wbinfo -s "$SIDG" | sed 's/.\{1\}$//' | cut -d "$WBSEP" -f2)
  10. echo -e "$ADUSER:$USERID:$ADUNAME:$GROUPID"
  11. done | column -tx -s:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement