Skip to content

Commit

Permalink
Merge pull request #88 from l-with/fix-import-issue-87
Browse files Browse the repository at this point in the history
fix-import
  • Loading branch information
l-with authored Sep 13, 2024
2 parents b8086cc + 8861526 commit 277f617
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions ldap/resource_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,18 @@ func resourceLDAPEntryImport(_ context.Context, d *schema.ResourceData, _ interf

func resourceLDAPEntryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
cl := m.(*client.Client)
// return diag.Errorf("should not read")

dn := d.Get(attributeNameDn).(string)

var attributes *[]string
{
var ldapEntry client.LdapEntry
dataJson := d.Get(attributeNameDataJson)
err := json.Unmarshal([]byte(dataJson.(string)), &ldapEntry.Entry)
if err != nil {
return diag.FromErr(err)
}
attributes = client.GetAttributeNames(&ldapEntry)
}

ldapEntry, err := cl.ReadEntryByDN(dn, "("+dummyFilter+")", attributes)
id := d.Id()
ldapEntry, err := cl.ReadEntryByDN(id, "("+dummyFilter+")", &[]string{"*"})
if err != nil {
if err.(*ldap.Error).ResultCode == ldap.LDAPResultNoSuchObject {
d.SetId("")
return nil
}
return diag.FromErr(err)
}
dn := id
d.Set(attributeNameDn, dn)
ignoreAndBase64Encode := getIgnoreAndBase64encode(d)
ignoreRDNAttributes := client.GetRDNAttributes(ldapEntry, dn)
if ignoreRDNAttributes != nil {
Expand Down

0 comments on commit 277f617

Please sign in to comment.