Skip to content

Commit

Permalink
Merge pull request #7 from drastawi/patch-1
Browse files Browse the repository at this point in the history
Use default DN if exists
  • Loading branch information
trevex authored Apr 19, 2021
2 parents 20fc7bd + ea91712 commit 0d0db4e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions provider/data_ldap_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,15 @@ func searchLDAPObject(d *schema.ResourceData, meta interface{}) error {

foundObject := searchResult.Entries[0]

var dn string
for _, key := range []string{"dn", "DN", "distinguished_name", "distinguishedName"} {
dn = foundObject.GetAttributeValue(key)
if dn != "" {
traceLog("Found Distinguished Name for object: %s = %q", key, dn)
break
dn := foundObject.DN

if dn == "" {
for _, key := range []string{"dn", "DN", "distinguished_name", "distinguishedName"} {
dn = foundObject.GetAttributeValue(key)
if dn != "" {
traceLog("Found Distinguished Name for object: %s = %q", key, dn)
break
}
}
}

Expand Down

0 comments on commit 0d0db4e

Please sign in to comment.