From 0689ee46fd706e64689df78f005bbd359aefe36d Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Tue, 15 Oct 2024 21:34:34 +0000 Subject: [PATCH] improve ModGroup to perform NOP --- app/ldap.go | 17 ++++++++++++++++- go.mod | 1 - 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/ldap.go b/app/ldap.go index 35a4604..efe84b1 100644 --- a/app/ldap.go +++ b/app/ldap.go @@ -278,7 +278,22 @@ func (l LDAPClient) AddGroup(gid string, group Group) (int, gin.H) { } func (l LDAPClient) ModGroup(gid string, group Group) (int, gin.H) { - return 200, gin.H{ + modifyRequest := ldap.NewModifyRequest( + fmt.Sprintf("cn=%s,%s", gid, l.groupsdn), + nil, + ) + + modifyRequest.Replace("cn", []string{gid}) + + err := l.client.Modify(modifyRequest) + if err != nil { + return http.StatusBadRequest, gin.H{ + "ok": false, + "error": err, + } + } + + return http.StatusOK, gin.H{ "ok": true, "error": nil, } diff --git a/go.mod b/go.mod index 7ac781e..5e3866a 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,6 @@ require ( github.com/gorilla/sessions v1.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect - github.com/knz/go-libedit v1.10.1 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect