summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-14 08:43:40 -0400
committerGitHub <noreply@github.com>2017-03-14 08:43:40 -0400
commitee457176bd0c4442358df089044b87eb75fe7569 (patch)
tree18ddf06b686b24925febc2e9a33f86dff4936c17 /model
parenta71a9fc3bff1b6a6c9d5e0a65f53686922572834 (diff)
downloadchat-ee457176bd0c4442358df089044b87eb75fe7569.tar.gz
chat-ee457176bd0c4442358df089044b87eb75fe7569.tar.bz2
chat-ee457176bd0c4442358df089044b87eb75fe7569.zip
Implement admin LDAP endpoints for APIv4 (#5720)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go27
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)
+ }
+}