summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-09 11:52:26 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:07 +0200
commit79700e690e44485b5037bd191934a56b6e765655 (patch)
tree76db763d00bd13f51809145d9cb450b270c033ef
parentf11648bfd7dfdacff5889dc3f12d89b59146b4f4 (diff)
downloadsamba-79700e690e44485b5037bd191934a56b6e765655.tar.gz
samba-79700e690e44485b5037bd191934a56b6e765655.tar.bz2
samba-79700e690e44485b5037bd191934a56b6e765655.zip
s3-winbind: Implemented samr backend function common_sid_to_name.
-rw-r--r--source3/winbindd/winbindd_samr.c75
1 files changed, 73 insertions, 2 deletions
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c
index a5cfede1a3..1f8d03cf7e 100644
--- a/source3/winbindd/winbindd_samr.c
+++ b/source3/winbindd/winbindd_samr.c
@@ -936,8 +936,79 @@ static NTSTATUS common_sid_to_name(struct winbindd_domain *domain,
char **name,
enum lsa_SidType *type)
{
- /* TODO FIXME */
- return NT_STATUS_NOT_IMPLEMENTED;
+ struct rpc_pipe_client *lsa_pipe;
+ struct policy_handle lsa_policy;
+ char *mapped_name = NULL;
+ char **domains = NULL;
+ char **names = NULL;
+ enum lsa_SidType *types = NULL;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS map_status;
+ NTSTATUS status;
+
+ DEBUG(3,("samr: sid to name\n"));
+
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto error;
+ }
+
+ /*
+ * We don't run into deadlocks here, cause winbind_off() is called in
+ * the main function.
+ */
+ status = rpccli_lsa_lookup_sids(lsa_pipe,
+ tmp_ctx,
+ &lsa_policy,
+ 1, /* num_sids */
+ sid,
+ &domains,
+ &names,
+ &types);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(2,("sid_to_name: failed to lookup sids: %s\n",
+ nt_errstr(status)));
+ goto error;
+ }
+
+ if (type) {
+ *type = (enum lsa_SidType) types[0];
+ }
+
+ if (name) {
+ map_status = normalize_name_map(tmp_ctx,
+ domain,
+ *name,
+ &mapped_name);
+ if (NT_STATUS_IS_OK(map_status) ||
+ NT_STATUS_EQUAL(map_status, NT_STATUS_FILE_RENAMED)) {
+ *name = talloc_strdup(mem_ctx, mapped_name);
+ DEBUG(5,("returning mapped name -- %s\n", *name));
+ } else {
+ *name = talloc_strdup(mem_ctx, names[0]);
+ }
+ if (*name == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto error;
+ }
+ }
+
+ if (domain_name) {
+ *domain_name = talloc_strdup(mem_ctx, domains[0]);
+ if (*domain_name == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto error;
+ }
+ }
+
+error:
+ TALLOC_FREE(tmp_ctx);
+ return status;
}
static NTSTATUS common_rids_to_names(struct winbindd_domain *domain,