diff options
author | Sumit Bose <sbose@redhat.com> | 2009-08-20 14:02:26 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-08-21 12:55:44 -0400 |
commit | aa80e585f843b754b6c0b4945472ebd6cfab0cf3 (patch) | |
tree | 56975d8c80fd6d353625655aa6333586c8294ebf /server/providers | |
parent | c1410419224a504954791dbfd36fd19ad78cfb65 (diff) | |
download | sssd-aa80e585f843b754b6c0b4945472ebd6cfab0cf3.tar.gz sssd-aa80e585f843b754b6c0b4945472ebd6cfab0cf3.tar.bz2 sssd-aa80e585f843b754b6c0b4945472ebd6cfab0cf3.zip |
store additional LDAP attributes
If available the original DN and the user principle will be stored
in sysdb.
Diffstat (limited to 'server/providers')
-rw-r--r-- | server/providers/ldap/sdap_async.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/server/providers/ldap/sdap_async.c b/server/providers/ldap/sdap_async.c index b71b61f2..7c6cd2c2 100644 --- a/server/providers/ldap/sdap_async.c +++ b/server/providers/ldap/sdap_async.c @@ -840,6 +840,7 @@ static struct tevent_req *sdap_save_user_send(TALLOC_CTX *memctx, long int l; uid_t uid; gid_t gid; + struct sysdb_attrs *user_attrs; req = tevent_req_create(memctx, &state, struct sdap_save_user_state); if (!req) return NULL; @@ -921,11 +922,51 @@ static struct tevent_req *sdap_save_user_send(TALLOC_CTX *memctx, } gid = l; + user_attrs = sysdb_new_attrs(state); + if (user_attrs == NULL) { + ret = ENOMEM; + goto fail; + } + + ret = sysdb_attrs_get_el(state->attrs, SYSDB_ORIG_DN, &el); + if (ret) { + goto fail; + } + if (el->num_values == 0) { + DEBUG(7, ("Original DN is not available for user [%s].\n", name)); + } else { + DEBUG(7, ("Adding original DN [%s] to attributes of user [%s].\n", + el->values[0].data, name)); + ret = sysdb_attrs_add_string(user_attrs, SYSDB_ORIG_DN, + (const char *) el->values[0].data); + if (ret) { + goto fail; + } + } + + ret = sysdb_attrs_get_el(state->attrs, + opts->user_map[SDAP_AT_USER_PRINC].sys_name, &el); + if (ret) { + goto fail; + } + if (el->num_values == 0) { + DEBUG(7, ("User principle is not available for user [%s].\n", name)); + } else { + DEBUG(7, ("Adding user principle [%s] to attributes of user [%s].\n", + el->values[0].data, name)); + ret = sysdb_attrs_add_string(user_attrs, SYSDB_UPN, + (const char *) el->values[0].data); + if (ret) { + goto fail; + } + } + DEBUG(6, ("Storing info for user %s\n", name)); - subreq = sysdb_store_user_send(state, state->ev, state->handle, - state->dom, name, pwd, uid, gid, - gecos, homedir, shell); + subreq = sysdb_store_user_with_attrs_send(state, state->ev, state->handle, + state->dom, name, pwd, uid, gid, + gecos, homedir, shell, + user_attrs); if (!subreq) { ret = ENOMEM; goto fail; @@ -946,7 +987,7 @@ static void sdap_save_user_done(struct tevent_req *subreq) struct tevent_req); int ret; - ret = sysdb_store_user_recv(subreq); + ret = sysdb_store_user_with_attrs_recv(subreq); talloc_zfree(subreq); if (ret) { tevent_req_error(req, ret); |