return KADM5_POLICY_REF;
}
krb5_db_free_policy(handle->context, entry);
- if ((ret = krb5_db_delete_policy(handle->context, name)))
- return ret;
- else
- return KADM5_OK;
+ ret = krb5_db_delete_policy(handle->context, name);
+ if (ret == KRB5_KDB_POLICY_REF)
+ ret = KADM5_POLICY_REF;
+ return (ret == 0) ? KADM5_OK : ret;
}
kadm5_ret_t
krb5_ldap_get_value(ld, ent, "krbpwdfailurecountinterval", &(pol_entry->pw_failcnt_interval));
krb5_ldap_get_value(ld, ent, "krbpwdlockoutduration", &(pol_entry->pw_lockout_duration));
- /* Get the reference count */
- pol_dn = ldap_get_dn(ld, ent);
- st = krb5_ldap_get_reference_count (context, pol_dn, "krbPwdPolicyReference",
- &(pol_entry->policy_refcnt), ld);
- ldap_memfree(pol_dn);
+ /*
+ * We don't store the policy refcnt, because principals might be maintained
+ * outside of kadmin. Instead, we will check for principal references when
+ * policies are deleted.
+ */
+ pol_entry->policy_refcnt = 0;
cleanup:
return st;
krb5_error_code
krb5_ldap_delete_password_policy(krb5_context context, char *policy)
{
- int mask = 0;
+ int mask = 0, refcount;
char *policy_dn = NULL, *class[] = {"krbpwdpolicy", NULL};
krb5_error_code st=0;
LDAP *ld=NULL;
if (st != 0)
goto cleanup;
+ st = krb5_ldap_get_reference_count(context, policy_dn,
+ "krbPwdPolicyReference", &refcount, ld);
+ if (st == 0 && refcount != 0)
+ st = KRB5_KDB_POLICY_REF;
+ if (st != 0)
+ goto cleanup;
+
/* Ensure that the object is a password policy */
if ((st=checkattributevalue(ld, policy_dn, "objectclass", class, &mask)) != 0)
goto cleanup;