mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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:
committed by
Rob Crittenden
parent
0eb56656e0
commit
c3c59ce15c
@@ -1760,33 +1760,37 @@ static krb5_error_code ipadb_modify_principal(krb5_context kcontext,
|
|||||||
LDAPMessage *lentry;
|
LDAPMessage *lentry;
|
||||||
struct ipadb_mods *imods = NULL;
|
struct ipadb_mods *imods = NULL;
|
||||||
char *dn = NULL;
|
char *dn = NULL;
|
||||||
|
struct ipadb_e_data *ied;
|
||||||
|
|
||||||
ipactx = ipadb_get_context(kcontext);
|
ipactx = ipadb_get_context(kcontext);
|
||||||
if (!ipactx) {
|
if (!ipactx) {
|
||||||
return KRB5_KDB_DBNOTINITED;
|
return KRB5_KDB_DBNOTINITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
kerr = krb5_unparse_name(kcontext, entry->princ, &principal);
|
ied = (struct ipadb_e_data *)entry->e_data;
|
||||||
if (kerr != 0) {
|
if (!ied || !ied->entry_dn) {
|
||||||
goto done;
|
kerr = krb5_unparse_name(kcontext, entry->princ, &principal);
|
||||||
}
|
if (kerr != 0) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
kerr = ipadb_fetch_principals(ipactx, principal, &res);
|
kerr = ipadb_fetch_principals(ipactx, principal, &res);
|
||||||
if (kerr != 0) {
|
if (kerr != 0) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: no alias allowed for now, should we allow modifies
|
/* FIXME: no alias allowed for now, should we allow modifies
|
||||||
* by alias name ? */
|
* by alias name ? */
|
||||||
kerr = ipadb_find_principal(kcontext, 0, res, &principal, &lentry);
|
kerr = ipadb_find_principal(kcontext, 0, res, &principal, &lentry);
|
||||||
if (kerr != 0) {
|
if (kerr != 0) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
dn = ldap_get_dn(ipactx->lcontext, lentry);
|
dn = ldap_get_dn(ipactx->lcontext, lentry);
|
||||||
if (!dn) {
|
if (!dn) {
|
||||||
kerr = KRB5_KDB_INTERNAL_ERROR;
|
kerr = KRB5_KDB_INTERNAL_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kerr = new_ipadb_mods(&imods);
|
kerr = new_ipadb_mods(&imods);
|
||||||
@@ -1800,7 +1804,11 @@ static krb5_error_code ipadb_modify_principal(krb5_context kcontext,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
kerr = ipadb_simple_modify(ipactx, dn, imods->mods);
|
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:
|
done:
|
||||||
ipadb_mods_free(imods);
|
ipadb_mods_free(imods);
|
||||||
|
|||||||
Reference in New Issue
Block a user