Skip to content

Commit

Permalink
Merge pull request #17 from barryib/update-group-member
Browse files Browse the repository at this point in the history
feat: Allow group members and description update
  • Loading branch information
pablo-ruth authored Mar 18, 2021
2 parents b6b2d11 + b6d4b36 commit b5b2013
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Ouest-France/terraform-provider-ldap
go 1.13

require (
github.com/Ouest-France/goldap v0.4.0
github.com/Ouest-France/goldap v0.5.1
github.com/go-ldap/ldap/v3 v3.2.4
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.3
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzU
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Ouest-France/goldap v0.4.0 h1:wkD1q5V2COkucE2HnQWqcgTHJH6J/A9WgwLZrnM4qWE=
github.com/Ouest-France/goldap v0.4.0/go.mod h1:RwWUzDNiNoS0UXEdAjcoIayOR5TTbHyqBbAmM5dcNJo=
github.com/Ouest-France/goldap v0.5.1 h1:4MVIa4QjIOGzaT3cC4kc3YmM3ZSJ1KxdxkqMOpCef+A=
github.com/Ouest-France/goldap v0.5.1/go.mod h1:RwWUzDNiNoS0UXEdAjcoIayOR5TTbHyqBbAmM5dcNJo=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down
19 changes: 16 additions & 3 deletions ldap/resource_ldap_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func resourceLDAPGroup() *schema.Resource {
"members": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand Down Expand Up @@ -125,8 +124,22 @@ func resourceLDAPGroupUpdate(ctx context.Context, d *schema.ResourceData, m inte
client := m.(*goldap.Client)
dn := fmt.Sprintf("CN=%s,%s", d.Get("name").(string), d.Get("ou").(string))

if err := client.UpdateGroup(dn, d.Get("name").(string), d.Get("description").(string)); err != nil {
return diag.FromErr(err)
if d.HasChange("members") {
members := []string{}
memberSet := d.Get("members").(*schema.Set)
for _, member := range memberSet.List() {
members = append(members, member.(string))
}

if err := client.UpdateGroupMembers(dn, members); err != nil {
return diag.FromErr(err)
}
}

if d.HasChange("description") {
if err := client.UpdateGroupDescription(dn, d.Get("description").(string)); err != nil {
return diag.FromErr(err)
}
}

return resourceLDAPGroupRead(ctx, d, m)
Expand Down

0 comments on commit b5b2013

Please sign in to comment.