s3-lsa: add lsa_lookup_trusted_domain_by_name and lsa_lookup_trusted_domain_by_sid.
authorGünther Deschner <gd@samba.org>
Thu, 16 Jul 2009 09:55:09 +0000 (11:55 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 16 Feb 2011 10:35:20 +0000 (11:35 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
source3/rpc_server/lsa/srv_lsa_nt.c

index 1a43b197aa3be755d01d3e5f635878a959fbb92a..4e504cb221f551958ca4577daca9acd988e3933c 100644 (file)
@@ -1408,6 +1408,66 @@ NTSTATUS _lsa_Close(struct pipes_struct *p, struct lsa_Close *r)
        return NT_STATUS_OK;
 }
 
+/***************************************************************************
+ ***************************************************************************/
+
+static NTSTATUS lsa_lookup_trusted_domain_by_sid(TALLOC_CTX *mem_ctx,
+                                                const struct dom_sid *sid,
+                                                struct trustdom_info **info)
+{
+       NTSTATUS status;
+       uint32_t num_domains = 0;
+       struct trustdom_info **domains = NULL;
+       int i;
+
+       status = pdb_enum_trusteddoms(mem_ctx, &num_domains, &domains);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       for (i=0; i < num_domains; i++) {
+               if (dom_sid_equal(&domains[i]->sid, sid)) {
+                       break;
+               }
+       }
+
+       if (i == num_domains) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       *info = domains[i];
+
+       return NT_STATUS_OK;
+}
+
+/***************************************************************************
+ ***************************************************************************/
+
+static NTSTATUS lsa_lookup_trusted_domain_by_name(TALLOC_CTX *mem_ctx,
+                                                 const char *netbios_domain_name,
+                                                 struct trustdom_info **info_p)
+{
+       struct dom_sid sid;
+       struct trustdom_info *info;
+
+       if (!pdb_get_trusteddom_pw(netbios_domain_name, NULL, &sid, NULL)) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       info = talloc(mem_ctx, struct trustdom_info);
+       if (!info) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       info->name      = talloc_strdup(info, netbios_domain_name);
+       NT_STATUS_HAVE_NO_MEMORY(info->name);
+       info->sid       = sid;
+
+       *info_p = info;
+
+       return NT_STATUS_OK;
+}
+
 /***************************************************************************
  ***************************************************************************/