-
-
Save SrDios/cc9d2305aeb4b400801c40bb6ccf6348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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