summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2011-05-30 15:10:44 -0400
committerSimo Sorce <ssorce@redhat.com>2011-08-26 08:24:49 -0400
commitd25370a57961cebaa75983bedca37b3fdf5094a2 (patch)
treed83bd45321b60f3536bc57cf7c4b67a8cf7aa90d /daemons
parent2f8caeab489a52e84045c70a1a175a7d0939ddf2 (diff)
downloadfreeipa-d25370a57961cebaa75983bedca37b3fdf5094a2.tar.gz
freeipa-d25370a57961cebaa75983bedca37b3fdf5094a2.tar.xz
freeipa-d25370a57961cebaa75983bedca37b3fdf5094a2.zip
ipa-kdb: add function to iterate over principals
Diffstat (limited to 'daemons')
-rw-r--r--daemons/ipa-kdb/ipa_kdb_principals.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/daemons/ipa-kdb/ipa_kdb_principals.c b/daemons/ipa-kdb/ipa_kdb_principals.c
index e697629f..d6a816f9 100644
--- a/daemons/ipa-kdb/ipa_kdb_principals.c
+++ b/daemons/ipa-kdb/ipa_kdb_principals.c
@@ -993,6 +993,46 @@ krb5_error_code ipadb_iterate(krb5_context kcontext,
int (*func)(krb5_pointer, krb5_db_entry *),
krb5_pointer func_arg)
{
- return KRB5_PLUGIN_OP_NOTSUPP;
+ struct ipadb_context *ipactx;
+ krb5_error_code kerr;
+ LDAPMessage *res = NULL;
+ LDAPMessage *lentry;
+ krb5_db_entry *kentry;
+ uint32_t pol;
+
+ ipactx = ipadb_get_context(kcontext);
+ if (!ipactx) {
+ return KRB5_KDB_DBNOTINITED;
+ }
+
+ /* fetch list of principal matching filter */
+ kerr = ipadb_fetch_principals(ipactx, match_entry, &res);
+ if (kerr != 0) {
+ goto done;
+ }
+
+ lentry = ldap_first_entry(ipactx->lcontext, res);
+
+ while (lentry) {
+
+ kentry = NULL;
+ kerr = ipadb_parse_ldap_entry(kcontext, NULL, lentry, &kentry, &pol);
+ if (kerr == 0 && pol != 0) {
+ kerr = ipadb_fetch_tktpolicy(kcontext, lentry, kentry, pol);
+ }
+ if (kerr == 0) {
+ /* Now call the callback with the entry */
+ func(func_arg, kentry);
+ }
+ ipadb_free_principal(kcontext, kentry);
+
+ lentry = ldap_next_entry(ipactx->lcontext, lentry);
+ }
+
+ kerr = 0;
+
+done:
+ ldap_msgfree(res);
+ return kerr;
}