ipa-kdb: Avoid lookup on modify if possible

This avoids one useless search if we already have the entry_dn.
This commit is contained in:
Simo Sorce
2012-02-13 22:21:17 -05:00
committed by Rob Crittenden
parent 0eb56656e0
commit c3c59ce15c

View File

@@ -1760,12 +1760,15 @@ static krb5_error_code ipadb_modify_principal(krb5_context kcontext,
LDAPMessage *lentry;
struct ipadb_mods *imods = NULL;
char *dn = NULL;
struct ipadb_e_data *ied;
ipactx = ipadb_get_context(kcontext);
if (!ipactx) {
return KRB5_KDB_DBNOTINITED;
}
ied = (struct ipadb_e_data *)entry->e_data;
if (!ied || !ied->entry_dn) {
kerr = krb5_unparse_name(kcontext, entry->princ, &principal);
if (kerr != 0) {
goto done;
@@ -1788,6 +1791,7 @@ static krb5_error_code ipadb_modify_principal(krb5_context kcontext,
kerr = KRB5_KDB_INTERNAL_ERROR;
goto done;
}
}
kerr = new_ipadb_mods(&imods);
if (kerr) {
@@ -1800,7 +1804,11 @@ static krb5_error_code ipadb_modify_principal(krb5_context kcontext,
goto done;
}
if (!ied || !ied->entry_dn) {
kerr = ipadb_simple_modify(ipactx, dn, imods->mods);
} else {
kerr = ipadb_simple_modify(ipactx, ied->entry_dn, imods->mods);
}
done:
ipadb_mods_free(imods);