diff options
author | Andreas Schneider <asn@samba.org> | 2010-06-07 21:20:15 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2010-07-05 15:59:06 +0200 |
commit | 48147555d2a2e879b027c09fb48c2ab7c40f4126 (patch) | |
tree | f5580228b20923f262ccf457e714880228a4fce5 /source3 | |
parent | 7ee0ebe40604123e38b02661ac9cba294ee23563 (diff) | |
download | samba-48147555d2a2e879b027c09fb48c2ab7c40f4126.tar.gz samba-48147555d2a2e879b027c09fb48c2ab7c40f4126.tar.bz2 samba-48147555d2a2e879b027c09fb48c2ab7c40f4126.zip |
s3-winbind: Implemented samr backend function sam_query_user.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/winbindd/winbindd_samr.c | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c index a4d92ce401..57a9d58292 100644 --- a/source3/winbindd/winbindd_samr.c +++ b/source3/winbindd/winbindd_samr.c @@ -386,8 +386,87 @@ static NTSTATUS sam_query_user(struct winbindd_domain *domain, const struct dom_sid *user_sid, struct wbint_userinfo *user_info) { - /* TODO FIXME */ - return NT_STATUS_NOT_IMPLEMENTED; + struct rpc_pipe_client *samr_pipe; + struct policy_handle dom_pol, user_pol; + union samr_UserInfo *info = NULL; + TALLOC_CTX *tmp_ctx; + uint32_t user_rid; + NTSTATUS status; + + DEBUG(3,("samr: query_user\n")); + + if (!sid_peek_check_rid(&domain->sid, user_sid, &user_rid)) { + return NT_STATUS_UNSUCCESSFUL; + } + + if (user_info) { + user_info->homedir = NULL; + user_info->shell = NULL; + user_info->primary_gid = (gid_t) -1; + } + + tmp_ctx = talloc_stackframe(); + if (tmp_ctx == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol); + if (!NT_STATUS_IS_OK(status)) { + goto error; + } + + /* Get user handle */ + status = rpccli_samr_OpenUser(samr_pipe, + tmp_ctx, + &dom_pol, + SEC_FLAG_MAXIMUM_ALLOWED, + user_rid, + &user_pol); + if (!NT_STATUS_IS_OK(status)) { + goto error; + } + + /* Get user info */ + status = rpccli_samr_QueryUserInfo(samr_pipe, + tmp_ctx, + &user_pol, + 0x15, + &info); + + rpccli_samr_Close(samr_pipe, tmp_ctx, &user_pol); + + if (!NT_STATUS_IS_OK(status)) { + goto error; + } + + sid_compose(&user_info->user_sid, &domain->sid, user_rid); + sid_compose(&user_info->group_sid, &domain->sid, + info->info21.primary_gid); + + if (user_info) { + user_info->acct_name = talloc_strdup(mem_ctx, + info->info21.account_name.string); + if (user_info->acct_name == NULL) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + user_info->full_name = talloc_strdup(mem_ctx, + info->info21.full_name.string); + if (user_info->acct_name == NULL) { + status = NT_STATUS_NO_MEMORY; + goto error; + } + + user_info->homedir = NULL; + user_info->shell = NULL; + user_info->primary_gid = (gid_t)-1; + } + + status = NT_STATUS_OK; +error: + TALLOC_FREE(tmp_ctx); + return status; } /* get a list of trusted domains - builtin domain */ |