Skip to content

Commit

Permalink
set id to empty if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
l-with committed Aug 17, 2024
1 parent 110ba80 commit b8086cc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ldap/resource_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/go-ldap/ldap/v3"
"strings"

"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -162,6 +163,10 @@ func resourceLDAPEntryRead(ctx context.Context, d *schema.ResourceData, m interf

ldapEntry, err := cl.ReadEntryByDN(dn, "("+dummyFilter+")", attributes)
if err != nil {
if err.(*ldap.Error).ResultCode == ldap.LDAPResultNoSuchObject {
d.SetId("")
return nil
}
return diag.FromErr(err)
}
ignoreAndBase64Encode := getIgnoreAndBase64encode(d)
Expand Down

0 comments on commit b8086cc

Please sign in to comment.