summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-08 14:42:59 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:07 +0200
commitf11648bfd7dfdacff5889dc3f12d89b59146b4f4 (patch)
treecbf014d5e40934c43c7d9d505c74fff75134e8d1 /source3/winbindd
parent483d4528d97670d13d1cdb69a041d587e6e2194f (diff)
downloadsamba-f11648bfd7dfdacff5889dc3f12d89b59146b4f4.tar.gz
samba-f11648bfd7dfdacff5889dc3f12d89b59146b4f4.tar.bz2
samba-f11648bfd7dfdacff5889dc3f12d89b59146b4f4.zip
s3-winbind: Implemented samr backend function common_name_to_sid.
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/winbindd_samr.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c
index 1c45da7656..a5cfede1a3 100644
--- a/source3/winbindd/winbindd_samr.c
+++ b/source3/winbindd/winbindd_samr.c
@@ -854,8 +854,78 @@ static NTSTATUS common_name_to_sid(struct winbindd_domain *domain,
struct dom_sid *sid,
enum lsa_SidType *type)
{
- /* TODO FIXME */
- return NT_STATUS_NOT_IMPLEMENTED;
+ struct rpc_pipe_client *lsa_pipe;
+ struct policy_handle lsa_policy;
+ enum lsa_SidType *types = NULL;
+ struct dom_sid *sids = NULL;
+ char *full_name = NULL;
+ char *mapped_name = NULL;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS status;
+
+ DEBUG(3,("samr: name to sid\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;
+ }
+
+ if (name == NULL || name[0] == '\0') {
+ full_name = talloc_asprintf(tmp_ctx, "%s", domain_name);
+ } else if (domain_name == NULL || domain_name[0] == '\0') {
+ full_name = talloc_asprintf(tmp_ctx, "%s", name);
+ } else {
+ full_name = talloc_asprintf(tmp_ctx, "%s\\%s", domain_name, name);
+ }
+
+ if (full_name == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ }
+
+ status = normalize_name_unmap(tmp_ctx, full_name, &mapped_name);
+ /* Reset the full_name pointer if we mapped anything */
+ if (NT_STATUS_IS_OK(status) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_FILE_RENAMED)) {
+ full_name = mapped_name;
+ }
+
+ DEBUG(3,("name_to_sid: %s for domain %s\n",
+ full_name ? full_name : "", domain_name ));
+
+ /*
+ * We don't run into deadlocks here, cause winbind_off() is
+ * called in the main function.
+ */
+ status = rpccli_lsa_lookup_names(lsa_pipe,
+ tmp_ctx,
+ &lsa_policy,
+ 1, /* num_names */
+ (const char **) &full_name,
+ NULL, /* domains */
+ 1, /* level */
+ &sids,
+ &types);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(2,("name_to_sid: failed to lookup name: %s\n",
+ nt_errstr(status)));
+ goto error;
+ }
+
+ if (sid) {
+ sid_copy(sid, &sids[0]);
+ }
+ if (type) {
+ *type = types[0];
+ }
+
+error:
+ TALLOC_FREE(tmp_ctx);
+ return status;
}
/* convert a domain SID to a user or group name */