diff --git a/go.mod b/go.mod index 885b7d2..7e48257 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index ea1a0e0..d734c26 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/ldap/resource_ldap_group.go b/ldap/resource_ldap_group.go index 1b66513..0e99313 100644 --- a/ldap/resource_ldap_group.go +++ b/ldap/resource_ldap_group.go @@ -39,7 +39,6 @@ func resourceLDAPGroup() *schema.Resource { "members": &schema.Schema{ Type: schema.TypeSet, Optional: true, - ForceNew: true, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -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)