-
Notifications
You must be signed in to change notification settings - Fork 0
/
unitySignOn.go
62 lines (57 loc) · 1.88 KB
/
unitySignOn.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
package connect
import "encoding/json"
type SignOn struct {
IsEnabled bool `json:"isEnabled"`
HostName string `json:"hostName"` // Hostname to the Kerio Unity Sign On server. Non default port can be added Eg: example.com:4444
UserName string `json:"userName"` // Administrator username
Password string `json:"password"` // [WRITE-ONLY] Administrator password
}
// UnitySignOnGet - Obtain Kerio Unity Sign On settings
// Return
// settings - Sign On settings
func (s *ServerConnection) UnitySignOnGet() (*SignOn, error) {
data, err := s.CallRaw("UnitySignOn.get", nil)
if err != nil {
return nil, err
}
settings := struct {
Result struct {
Settings SignOn `json:"settings"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &settings)
return &settings.Result.Settings, err
}
// UnitySignOnSet - Set Kerio Unity Sign On settings
// Parameters
// settings - Sign On settings
func (s *ServerConnection) UnitySignOnSet(settings SignOn) error {
params := struct {
Settings SignOn `json:"settings"`
}{settings}
_, err := s.CallRaw("UnitySignOn.set", params)
return err
}
// UnitySignOnTestConnection - Test connection to Kerio Unity Sign On server
// Parameters
// hostNames - directory server (primary and secondary if any)
// credentials - authentication information
// Return
// errors - error messages list; If no error is listed, connection is successful
func (s *ServerConnection) UnitySignOnTestConnection(hostNames StringList, credentials Credentials) (ErrorList, error) {
params := struct {
HostNames StringList `json:"hostNames"`
Credentials Credentials `json:"credentials"`
}{hostNames, credentials}
data, err := s.CallRaw("UnitySignOn.testConnection", params)
if err != nil {
return nil, err
}
errors := struct {
Result struct {
Errors ErrorList `json:"errors"`
} `json:"result"`
}{}
err = json.Unmarshal(data, &errors)
return errors.Result.Errors, err
}