Skip to content

Instantly share code, notes, and snippets.

@SrDios SrDios/getUsers.go Secret
Created Oct 23, 2018

Embed
What would you like to do?
groups := getADGroupsByTeenant()
for _, g := range groups {
usersAD := getADMembersFromGroup(g.DisplayName) //Get all membres from the different groups
}
func getADMembersFromGroup(groupName string) (users []adUser) {
out, err := exec.Command("az", "ad", "group", "member", "list", "-g", groupName).Output()
if err != nil {
log.Fatal("Error: ", err)
} else {
users = unMarshalGroups(out)
}
return users
}
func unMarshalGroups(out []byte) (users []adUser) {
if err := json.Unmarshal(out, &users); err != nil {
color.R.Printf(err.Error())
} else {
for _, user := range users {
fmt.Printf("\n%s", user.DisplayName)
}
}
return users
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.