-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (30 loc) · 769 Bytes
/
main.go
File metadata and controls
34 lines (30 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
"github.com/open-networks/go-msgraph"
"github.com/spf13/viper"
)
func config() *msgraph.GraphClient {
viper.SetConfigFile("config.yaml")
viper.ReadInConfig()
graphClient, err := msgraph.NewGraphClient(viper.GetString("TENANTID"), viper.GetString("CLIENTID"), viper.GetString("SECRET"))
if err != nil {
fmt.Println("Credentials are invalid: ", err)
}
return graphClient
}
func main() {
client := config()
groups, err := client.ListGroups()
if err != nil {
fmt.Printf("Error: " + err.Error())
} else {
for _, g := range groups {
fmt.Printf("\nGroup: %s\n===================\n\n", g.DisplayName)
members, _ := g.ListMembers()
for _, u := range members {
fmt.Printf("User: %s\n", u.DisplayName)
}
}
}
}