diff options
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index 38b89e74f..e9644ada0 100644 --- a/model/client4.go +++ b/model/client4.go @@ -186,6 +186,10 @@ func (c *Client4) GetSamlRoute() string { return fmt.Sprintf("/saml") } +func (c *Client4) GetLdapRoute() string { + return fmt.Sprintf("/ldap") +} + func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) { return c.DoApiRequest(http.MethodGet, url, "", etag) } @@ -1461,3 +1465,26 @@ func (c *Client4) GetClusterStatus() ([]*ClusterInfo, *Response) { return ClusterInfosFromJson(r.Body), BuildResponse(r) } } + +// LDAP Section + +// SyncLdap will force a sync with the configured LDAP server. +func (c *Client4) SyncLdap() (bool, *Response) { + if r, err := c.DoApiPost(c.GetLdapRoute()+"/sync", ""); err != nil { + return false, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} + +// TestLdap will attempt to connect to the configured LDAP server and return OK if configured +// correctly. +func (c *Client4) TestLdap() (bool, *Response) { + if r, err := c.DoApiPost(c.GetLdapRoute()+"/test", ""); err != nil { + return false, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return CheckStatusOK(r), BuildResponse(r) + } +} |