-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
71 lines (63 loc) · 2.24 KB
/
main.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"flag"
"fmt"
"os"
"strconv"
"github.com/sjeandeaux/azure-ad-go/information"
"github.com/sjeandeaux/azure-ad-go/log"
"github.com/sjeandeaux/azure-ad-go/soap"
"github.com/sjeandeaux/azure-ad-go/ugly"
)
//commandLineArgs all parameters in command line
type commandLineArgs struct {
user string
password string
clientID string
tenantDomain string
tenantID string
verbose bool
}
var commandLine = &commandLineArgs{}
//init configuration
func init() {
log.Logger.SetOutput(os.Stdout)
flag.StringVar(&commandLine.user, "user", os.Getenv("AZURE_AD_USER"), "user for Azure AD")
flag.StringVar(&commandLine.password, "password", os.Getenv("AZURE_AD_PASSWORD"), "user for Azure AD")
flag.StringVar(&commandLine.clientID, "clientID", os.Getenv("AZURE_AD_CLIENT_ID"), "The client ID")
flag.StringVar(&commandLine.tenantDomain, "tenantDomain", os.Getenv("AZURE_AD_TENANT_DOMAIN"), "Th tenant domain")
flag.StringVar(&commandLine.tenantID, "tenantID", os.Getenv("AZURE_AD_TENANT_ID"), "The tenant ID")
verbose, _ := strconv.ParseBool(os.Getenv("AZURE_AD_VERBOSE"))
flag.BoolVar(&commandLine.verbose, "verbose", verbose, "verbose")
flag.Parse()
}
func main() {
log.Logger.Println(information.Print())
uglyGet := ugly.NewMonitoringAzureAD(commandLine.user, commandLine.password)
if dir, err := uglyGet.GetDirSyncManagement(); err != nil {
log.Logger.Panicln(err)
} else {
log.Logger.Println(fmt.Sprintf("%+v", dir))
}
//soap
soapGet := soap.NewMonitoringAzureAD(commandLine.user, commandLine.password, commandLine.clientID, commandLine.tenantDomain, commandLine.tenantID, commandLine.verbose)
//aaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!!!!!!
if token, err := soapGet.AccessToken(soap.Graph); err != nil {
log.Logger.Panicln(err)
} else {
if dataBlob, err := soapGet.MsolConnect(token); err != nil {
log.Logger.Panicln(err)
} else {
if datum, err := soapGet.GetCompanyInformation(token, dataBlob); err != nil {
log.Logger.Panicln(err)
} else {
log.Logger.Printf("%+v", datum)
}
if datum, err := soapGet.HasObjectsWithDirSyncProvisioningErrors(token, dataBlob); err != nil {
log.Logger.Panicln(err)
} else {
log.Logger.Printf("%+v", datum)
}
}
}
}