Skip to content

Commit 0d0db4e

Browse files
authored
Merge pull request #7 from drastawi/patch-1
Use default DN if exists
2 parents 20fc7bd + ea91712 commit 0d0db4e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

provider/data_ldap_object.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,15 @@ func searchLDAPObject(d *schema.ResourceData, meta interface{}) error {
189189

190190
foundObject := searchResult.Entries[0]
191191

192-
var dn string
193-
for _, key := range []string{"dn", "DN", "distinguished_name", "distinguishedName"} {
194-
dn = foundObject.GetAttributeValue(key)
195-
if dn != "" {
196-
traceLog("Found Distinguished Name for object: %s = %q", key, dn)
197-
break
192+
dn := foundObject.DN
193+
194+
if dn == "" {
195+
for _, key := range []string{"dn", "DN", "distinguished_name", "distinguishedName"} {
196+
dn = foundObject.GetAttributeValue(key)
197+
if dn != "" {
198+
traceLog("Found Distinguished Name for object: %s = %q", key, dn)
199+
break
200+
}
198201
}
199202
}
200203

0 commit comments

Comments
 (0)